美好的一天!
我有一个具有以下属性的对象学生:
class Student
String name
Date birthday
Run Code Online (Sandbox Code Playgroud)
我使用arrayList来存储学生对象我的问题是,如何使用collecitons排序按生日对StudentList进行排序?
List <Student> studentList = new ArrayList<Student>();
Run Code Online (Sandbox Code Playgroud)
我该如何编码呢?
Collections.sort(????);
谢谢
我想在页面中缓存以下JSON对象,以便我可以在另一个页面上检索它.
var test = {
"lists":["list1","list2","list3","list4","list5"],
"maps": {
"key4":"value4","key3":"value3","key5":"value5","key2":"value2","key1":"value1"
},
"number1":123456789,
"numberarray1":[1,2,3,4,5,6,7,8,9],
"string1":"A",
"stringarray1":["A1","B1"]
}
Run Code Online (Sandbox Code Playgroud)
如何缓存它并再次检索它?
这可能吗?如果没有,我可以通过其他方式保存我的JSON对象,然后在另一个页面上检索它.
谢谢.
美好的一天!
我的代码中出现以下错误:
<?php
if (!$_POST['SUBMIT']){ //ERROR: Undefined index
?>
<H2>Add Employee</H2>
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">SSN</td>
<td><input name="SSN" type="text" id="SSN"></td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="SUBMIT" type="SUBMIT" id="ADD" value="ADD"></td>
</tr>
</table>
</form>
<?php
}
else {
//code here
}
?>
Run Code Online (Sandbox Code Playgroud)
如何删除上面的错误?谢谢.
我想将一个活动类中的位置值传递给另一个活动类......
我的代码如下:
protected void onListItemClick(ListView listView, View v, int position,
long id) {
switch (position) {
case 1:
Intent newActivity1 = new Intent(this, BucketItemActivity.class);
newActivity1.putExtra("bucketno", position);
startActivity(newActivity1);
break;
case 2:
Intent newActivity2 = new Intent(this, BucketItemActivity.class);
newActivity2.putExtra("bucketno", position);
startActivity(newActivity2);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
将接收它的活动类..
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bucket_item);
String value = getIntent().getExtras().getString("bucketno");
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(value);
setContentView(textView);
}
Run Code Online (Sandbox Code Playgroud)
但我总是在String值中得到一个null ...
请帮忙.
美好的一天!
我在html中的选择框有问题.我在我的简单CRUD项目的EDIT部分,在用户可以编辑之前,首先显示所选数据,然后通过servlet在数据库中检索它.
现在我希望我检索的数据是我的选择框中的SELECTED(默认值). ${product.category}
<select size="1" name="category">
<option value ="1">Dogs</option>
<option value ="2">Cats</option>
<option value ="5">Others</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我尝试像这样插入但它不起作用.
<select size="1" name="category" selected=${product.category}>
<option value ="1">Dogs</option>
<option value ="2">Cats</option>
<option value ="5">Others</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情..如果($ {product.category} == 1),选择=选项1 ......
我见过像这在论坛中的一个,但它是在PHP格式.我怎么能用JSP做到这一点?
非常感谢你.
美好的一天!
我正在阅读Manning的struts2书,其中一个主题是使用语法使用OGNL访问静态变量 @[fullClassName]@[property or methodCall]
所以我在我的程序上尝试了它,我的代码如下:
豆:
public class ContactsBean {
private static int count = 1;
//getter and setter
}
Run Code Online (Sandbox Code Playgroud)
行动:
private ContactsBean contacts;
//getters and setters
Run Code Online (Sandbox Code Playgroud)
JSP:
<s:property value="@com.demo.bean.ContactsBean@count" />
or
<s:property value="@vs@count" /> //valuestack method
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我错过了什么吗?谢谢.
我们的教授要求我们通过使用堆栈检查一个单词是否是回文.每次我运行它都会出错:Unhandled Exception. Access violation我做错了什么?我该如何改进我的代码?我的代码如下:
typedef struct stack{
char name;
struct stack * next;
}Stack;
void push(Stack**head, char value);
char pop(Stack**head);
int main(){
char word[11];
int i=0;
int lenght = 0;
Stack*head = NULL;
printf("Please type the word: ");
scanf("%s", word);
lenght = strlen(word);
while(word[i]!='\0'){
push(&head, word[i]);
i++;
}
i = 0;
while(pop(&head)==word[i]){
i++;
}
if(i==lenght) printf("The word is a palindrome");
else printf("The word is not a palindrome");
}
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何枚举javascript对象的属性?
美好的一天!
我想通过以下代码确定使用javascript导航器的所有属性:
<script type="text/javascript">
for(var property in navigator){
str="navigator."+ property; //HAVING A PROBLEM HERE...
document.write(property+ " <em>"+
str+"</em><br />");
}
</script>
Run Code Online (Sandbox Code Playgroud)
但我的str变量的串联打印原样.我需要的是房产的实际价值.
例如.navigator.appCodeName应该打印mozilla而不是navigator.appCodeName本身.
先感谢您.
我有时互换使用NOT IN,并NOT EXIST在我的SQL查询,都产生相同的结果.背后的逻辑NOT EXIST是一样的NOT IN吗?因为我认为NOT IN......(在子查询中被评估为"OR")等于NOT EXIST(也被评估为"OR")?或者我错过了什么?
我有一个链接到另一个页面的按钮.在我单击该链接之前,我想检查该页面当前是否返回错误或是否存在错误.我该如何编码呢?这可能吗?如果链接不存在或者它返回错误,我想禁用链接.