Java¶ÔÏó¿½±´
public class Person implements Serializable {
private String name;
private int age;
private GregorianCalendar birthday;
public Person(){
}
public Person(String name, int age, GregorianCalendar birthday){
this.name = name;
this.age = age;
this.birthday = birthday;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public GregorianCalendar getBirthday() {
return birthday;
}
public void setBirthday(GregorianCalendar birthday) {
this.birthday = birthday;
}
public static void main(String[] args) {
Person p = new Person("ÕÅÈý",13,new GregorianCalendar(1985,8,1));
Person p2 = null;
try{
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteOut);
oos.writeObject(p);
Ïà¹ØÎĵµ£º
ÏÈÀ´Á˽âÒ»ÏÂÁ´±íģʽµÄÔÀí£º
Ê×ÏÈдһ¸öJavaBean£¬ÄÚÈÝÊÇÒªÌí¼ÓµÄÔªËØºÍ¸ÃÔªËØµÄ½Úµã¡£
public class NodeBean implements Serializable
{
private Object data; //ÔªËØ±¾Éí
private NodeBean next; //ÏÂÒ»¸ö½Úµã
&n ......
//=============================Êä³öÆæÊý
public class OddTest {
public static boolean isOdd(int i){
return i % 2 != 0; //±È½Ï i % 2 == 0;×¢£º -1%2 = -1
}
public static void main(String[] args) {
for(int i = -10; i <= 10; i++) {
System.out.println(isOdd(i));
}
}
}
// ......
1£¬intÓëbytes ת»»
intת»»³Ébytes
public
static
final
byte
[]
int2bytes
(
int
value
)
{
return
new
byte
[]
{
(
byte
)(
value
>>>
24
),
(
byte
)(
value
>>>
16
),
......
ÉÏÒ»´Î£¬ÎÒÃÇÍê³ÉÁ˽çÃæµÄ×éÖ¯¡£½ÓÏÂÀ´ÎÒÃÇÍê³ÉÒµÎñÂß¼¡£
1£©ÈçºÎÍê³ÉÖÜΧÏàÁڵİ´Å¥±äÉ«¡£
·ÖÎö£ºÒòΪÎÒÃÇ×öÁËÒ»¸ö5*5µÄÊý×é¡£²¢ÇÒÊÂÏÈÎÒÃǸøÃ¿¸ö×Ô¶¨ÒåµÄbutton¼ÓÁËxºÍy×ø±ê
¾ÍÊÇΪÁ˸ü·½±ãµÄ¸øÏàÁڵİ´Å¥±äÉ«¡£
µ±ÎÒÃǵã»÷(2£¬2)°´Å¥Ê±£¬ÖÜΧµÄ 4¸ö°´Å¥»á±ä»¯¡£
µ±È»Ê×ÏÈÎÒÃÇÓ¦¸ÃÏȸøÃ¿¸ö°´Å¥Ôö¼Ó¼àÌýÆ÷¡£Î ......
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
/**
* ÇóÖÊÊýºÍ£¬
* Èç:
* sum(1)=2=2
* sum(2)=2+3=5
* sum(3)=2+3+5=10
* sum(4)=2+3+5+7=17
& ......