import java.io.IOException;
/**
* @Author:王强哥
*/
public class Hello {
/**
* public :表示公有的,权限修饰符
* class :java中的关键字,用来修饰一个类
* Hello:是类名
*/
public static void main(String[] args) throws IOException{
/**
* static :关键字 表示静态的
* void :关键字 表示没有返回值类型
* main:表示主方法名 是java程序的入口
* IDEA中飘红的错误,统称为编译错误
* (String args)表示形参变量 String类型的数组 args是形参变量名
*/
System.out.println("Hello World!!!");
System.out.println("王强");
System.out.println("软件工程");
System.out.println("有志者,事竟成!");
}
}
public class VariableDemo01 {
public static void main(String[] args) {
//1.变量在使用之前必须提前声明
//System.out.println("age="+age);
//2.变量在使用之前必须先初始化
//int age;
//System.out.println("age="+age);
//3.变量不能重复定义
int age=18;
//int age=20;
System.out.println("age="+age);
}
}
public class VariableDemo02 {
public static void main(String[] args) {
//1.由数字、字母、下划线、$组成、其中数字不能开头
int number = 13;
//2.长度没有限制,但不宜过长
//int sabfiasnfinasifnasinfiwenfoin = 23;
//System.out.println(sabfiasnfinasifnasinfiwenfoin);
//3.不能使用java中的关键字和保留字
String str = "嘿嘿";
//4.尽量做到见名思意,支持中文,但不推荐
System.out.println("----------------");
String username = "王帆";
//String 姓名="王小凡";
System.out.println(username);
//System.out.println(姓名);
}
}
笔记也是总结到了代码里面。
早上学习了如何通过代码让电脑关机
import java.io.IOException;
public class Close {
public static void main(String[] args) throws IOException{
Runtime.getRuntime().exec("shutdown -s -t 3600");
System.out.println("家人,你的电脑将在3600后关机");
}
}
import java.io.IOException;
public class Close {
public static void main(String[] args) throws IOException{
Runtime.getRuntime().exec("shutdown -a");
System.out.println("家人,你的电脑将取消自动关机");
}
}