Java variable declaration

Title description

Fill in the 5 blanks in the following program according to the requirements of the notes, then read the program, write the running result of the program, and compare it with the actual running result. Finally, copy the completed program to the user code box and submit.

public class Main {
    
    
	public (填空1void main(String[] args) {
    
    //主方法main
		(填空2;// 声明一个初值为5的int类型变量intA
		(填空3// 声明两个float类型的变量f1和f2,f1的初值为实数10.2,f2没初值
		(填空4;// 声明一个初值为21.0的double类型变量d
		(填空5// 声明三个char类型的变量c1、c2、c3,初值分别为数字字符1、小写字母a、单引号'
		
		System.out.println("intA="+intA);
		f2=2*f1;
		System.out.println("f1="+f1+",f2="+f2);
		System.out.println("c1="+c1+",c2="+c2+",c3="+c3);
	}
}

Enter description

Output description

所声明变量的值

Sample output

intA=5
f1=10.2,f2=20.4
c1=1,c2=a,c3='

code

public class Main {
    
     
	public  static void main(String[] args) {
    
     // 主方法
       	int A = 5;// 声明一个初值为5的int类型变量intA
   		float f1 = 10.2f;  // 声float类型的变量f1,f1的初值为实数10.2
   		float f2;  // 声float类型的变量f2,f2没初值
   		double d = 21.0; // 声明一个初值为21.0的double类型变量d
   		char c1 = '1';  // 声明char类型的变量c1,初值为数字字符1
        char c2 = 'a';  // 声明char类型的变量c2,初值为小写字母a
        char c3 = '\''; // 声明char类型的变量c3,初值为单引号'
   		System.out.println("intA=" + A);
   		f2 = 2 * f1;
   		System.out.println("f1=" + f1 + ",f2=" + f2);
   		System.out.println("c1=" + c1 + ",c2=" + c2 + ",c3=" + c3);
	}
}

Guess you like

Origin blog.csdn.net/qq_44989881/article/details/112337182