LẬP TRINH HƢỚ NG ĐÔ
́
I TƢỢNG TRONG JAVA
phần 6
III.
N
, t
.
- C
Float(double n)
Float(float n)
Float(string str)
Double(double n)
Double(string str)
T
2. Cc phƣơng thc thƣng dng cho cc lp kiu s
-
nhau
byte byteValue() // tr
short shortValue()
int intValue()
long longValue()
double doubleValue()
float floatValue()
= :
- boolean equals(floatObj f ) : =
- string toString() :
.
, , Integer,
String
: Integer i = new Integer(20);
System.out.println(i.toString());
- static String toString(var n) :
String s = Integer.toString(25) // Cho chul
- static Float valueOf(String str) :
,
if ( (s.length() <=20) && (s.length() != 0) ) {
System.out.println("Ho va ten la : "+ s);
break;
}
System.out.println("Phai nhap ho ten khong qua 20 ky tu");
}
// Nhap nam sinh
while (true) {
try {
System.out.print("Nhap nam sinh : ");
s = kbd.readLine();
int i =Integer.parseInt(s);
if ((i<=1970) || (i>=2100)) throw new
NumberFormatException();
System.out.println("Nam sinh la : "+i);
break;
}
catch (IOException e){}
catch(NumberFormatException e){
System.out.println("Ban Phai nhap lai nam sinh trong
khoang
1970 den 2100");
}
}
}
5
MC LC
I.
1.
2.
II.
1.
6.
7. N
8.
IV.
1.
2.
3. T
V.
VI.
(
) (
)
1. C
2.
2.
IX.
1.
2.
3.
ng :
I.
1.
2.
3.