2013年12月4日星期三

Do not quite understand the value of student property age is when given ah ?

a, b is not initialized, not allocated memory space, the error can be understood .
name and age are not in the new student when he allocated memory space? int default 0, string default null
But if I want in the database ( the database is to allow the float is null ) then save the salaries salary ,
0.0 represents wages made ​​it to 0,
null said wages did not send ,
how this achieved?

public class test {

/**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
Person person=new Person();
System.out.println(person.age);
System.out.println(person.name);
System.out.println(person.salary);

int a;
System.out.println(a);
String b;
System.out.println(b);

}

}

class Person {
public String name;
public int age;
public float salary;


}


------ Solution ------------------------------------- -------

their landlord to solve the problem
------ Solution ------------------------------ can be null, like int and Internet, double and Double -------------- value
float as the value of null, Float is not , is the basic data types and encapsulation java type is not the same, the specific differences between a lot of investigation Kazakhstan
------ Solution ------------------------- -------------------
 and then study it before posting . .
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
can take points yet
------ For reference only ---------------------------------------
is not my salary would not with a float type , only to turn up with string ?
However, the design of this level in terms of float data type to represent a reasonable wage should be better than string type fishes
------ For reference only ------------- --------------------------
tried it, feel with Float instead of float can be solved . . .

没有评论:

发表评论