class Dog {
static int count = 0;
String name;
String gender;
}
public class Main {
public static void main(String[] args) {
Dog obj = new Dog();
// Increase count by one
Dog.count++;
obj.name = "Java";
obj.gender = "Male";
obj.name = "XML";
String changedName = obj.name;
}
}
public class Main {
byte b;
short s;
int i;
long l;
float f;
double d;
boolean bool;
String str;
public static void main(String[] args) {
Main obj = new Main();
System.out.println("byte is initialized to " + obj.l);
System.out.println("short is initialized to " + obj.s);
System.out.println("int is initialized to " + obj.i);
System.out.println("long is initialized to " + obj.l);
System.out.println("float is initialized to " + obj.f);
System.out.println("double is initialized to " + obj.d);
System.out.println("boolean is initialized to " + obj.bool);
System.out.println("String is initialized to " + obj.str);
}
}
更多建議: