import java.util.Scanner; public class 绝对值 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); if(a<0){ a=-a; } System.out.println(a); } }
值得一提的是import java.util.Scanner和Scanner scanner = new Scanner(System.in)的作用是在控制台输入数据得到结果