2.定义变量
class T02{
public static void main(String[]
args){
int a;
a=3;
System.out.println("a="+a);
}
}
3.数据输入输出
import java.util.Scanner;
class T03{
public static void main(String[] args){
Scanner scan=new
Scanner(System.in);
int a=scan.nextInt();
int
b=scan.nextInt();
int c=a+b;
System.out.println("a+b="+c);
}
}
4.判断
import java.util.Scanner;
class T04{
public
static void main(String[] args){
Scanner scan=new
Scanner(System.in);
int a=scan.nextInt();
int
b=scan.nextInt();
if(a+b>0)
System.out.println(1);
else
System.out.println(-1);
}
}
5.循环
import java.util.Scanner;
class T04{
public
static void main(String[] args){
Scanner scan=new
Scanner(System.in);
int n=scan.nextInt();
int
s=0;
for(int i=1;i<=n;i++)
s=s+i;