最贊回答 / 煙雨清風(fēng)
float:單精度類型,精度是8位有效數(shù)字,取值范圍是10的-38次方到10的38次方,float占用4個(gè)字節(jié)的存儲(chǔ)空間double:雙精度類型,精度是17位有效數(shù)字,取值范圍是10的-308次方到10的308次方,double占用8個(gè)字節(jié)的存儲(chǔ)空間若不聲明的,默認(rèn)小數(shù)都用double來(lái)表示,所以如果要用float的話,則應(yīng)該在其后加上f例如:float a=1.63;//會(huì)顯示錯(cuò)誤,正確的寫法為float a=1.63f;則會(huì)提示不能將double轉(zhuǎn)化成float 這成為窄型轉(zhuǎn)化注意float是8位有效...
2021-05-14
public class HelloWorld {
public static void main(String[] args) {
int score = 94;
String sex = "女";
if(score>=80){
if(sex.equals("男")){
System.out.println("進(jìn)入男子組決賽");
}else{
System.out.println("進(jìn)入女子組決賽");
}
}else{
System.out.println("出局");
}
public static void main(String[] args) {
int score = 94;
String sex = "女";
if(score>=80){
if(sex.equals("男")){
System.out.println("進(jìn)入男子組決賽");
}else{
System.out.println("進(jìn)入女子組決賽");
}
}else{
System.out.println("出局");
}
2021-05-14
public class HelloWorld {
public static void main(String[] args) {
int age=25;
if(age<18){
System.out.println("童年");
}else if(age>=18&age<40){
System.out.println("少年");
}else if(age>=40&age<60){
System.out.println("中年");
}else{
System.out.println("老年");
}
public static void main(String[] args) {
int age=25;
if(age<18){
System.out.println("童年");
}else if(age>=18&age<40){
System.out.println("少年");
}else if(age>=40&age<60){
System.out.println("中年");
}else{
System.out.println("老年");
}
2021-05-14
int[] scores = { 78, 93, 97, 84, 63 };
System.out.println("數(shù)組中的第2個(gè)成績(jī)?yōu)椋?quot; + scores[1] );
System.out.println("數(shù)組中的第2個(gè)成績(jī)?yōu)椋?quot; + scores[1] );
2021-05-11
int score = 53;
int count = 0;
System.out.println("加分前成績(jī):"+score);
while(score<60){
score++;
count++;
}System.out.println("加分后成績(jī):"+score);
System.out.println("共加了"+count+"次!");
int count = 0;
System.out.println("加分前成績(jī):"+score);
while(score<60){
score++;
count++;
}System.out.println("加分后成績(jī):"+score);
System.out.println("共加了"+count+"次!");
2021-05-11