override toString() ͧʷ¹
:: ¹ҡѹ :: ѡ String ѹ
หน้า 1 จาก 1
override toString() ͧʷ¹
class Student {
private String ;
private int ;
public Student(String , int ) {
this. = ;
this. = ;
}
public String toString() {
return " "++" "++" ";
}
}
**********************************************************
package string;
public class toString {
public static void main(String[] args) {
Student s1 = new Student("",25);
Student s2 = new Student("ѹ",30);
System.out.println(s1); // ¡ toString();
System.out.println("---------------------------------");
System.out.println(s2); // ¡ toString();
}
}
šѹ
25
---------------------------------
ѹ 30
private String ;
private int ;
public Student(String , int ) {
this. = ;
this. = ;
}
public String toString() {
return " "++" "++" ";
}
}
**********************************************************
package string;
public class toString {
public static void main(String[] args) {
Student s1 = new Student("",25);
Student s2 = new Student("ѹ",30);
System.out.println(s1); // ¡ toString();
System.out.println("---------------------------------");
System.out.println(s2); // ¡ toString();
}
}
šѹ
25
---------------------------------
ѹ 30
:: ¹ҡѹ :: ѡ String ѹ
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ