if ((index + 1) > imagesId.length) {
imageSwitcher.setImageResource(imagesId[index]);
} else {
imageSwitcher.setImageResource(imagesId[index + 1]);
}
三元运算符
int id = (index + 1) > imagesId.length ?index: index+1;
imageSwitcher.setImageResource(imagesId[id]) ;
public static String subString(String filename) {
String name = filename;
int last = filename.lastIndexOf(".") != -1 ? filename.lastIndexOf(".")
: -1;
if (last != -1) {
name = filename.substring(0, last);
name = subString(name);
}
return name;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (obj3 == obj4) {
((EditText) findViewById(R.id.EditText02))
.setText("obj3和obj4是同一对象实例");
} else {
((EditText) findViewById(R.id.EditText02))
.setText("obj3和obj4不是同一对象实例");
}
三元运算符 表达
((EditText) findViewById(R.id.EditText02)).setText(obj3==obj4?"obj3和obj4是同一对象实例":"obj3和obj4不是同一对象实例");