day05 Java运行机制及一些基础语法
Java运行机制及一些基础语法
- 编译型
- 解释型
IDEA安装
- 什么是IDE
集成开发环境(IDE,Integrated Development Environment )是用于提供程序开发环境的应用程序,一般包括代码编辑器、编译器、调试器和图形用户界面等工具。集成了代码编写功能、分析功能、编译功能、调试功能等一体化的开发软件服务套。
- IDEA介绍
- IDEA官网:
IDEA语言快捷键
- psvm:public static void main(String[] args)
- sout:System.out.println
java基础语法
注释
java中的注释有三种:
- 单行注释 //注释
- 多行注释 /* 注释 */
- 文档注释 /** 注释 */
public class Helloworld {
public static void main(String[] args) {
//单行注释:只能注释一行文字 //注释
//输出一个helloworld
String teacher = "王川";
System.out.println("Hello,World!");
//多行注释:可以注释多行文字 /* 注释 */
/*
我是多行注释
我是多行注释
*/
//JavaDoc:文档注释 /** 注释 */
/**
* @description helloworld
* @author 王川
*/
//有趣代码注释
/***
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ___/`---'\____
* . ' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /--.--\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=---='
* .............................................
* 佛曰:bug泛滥,我已瘫痪!
*/
}
}
标识符
- 关键字
class public。。。。。
- 标识符注意点
- 不能使用关键字作为变量名或方法名
- 标识符是大小写敏感的
public class demo01 {
public static void main(String[] args) {
String Ahello = "wangchuan";
System.out.println(Ahello);
String hello = "wangchuan";
String $hello = "wangchuan";
String _hello = "wangchuan";
//String 1hello = "wangchuan";
//String #hello = "wangchuan";
//String *hello = "wangchuan";
String A1hello = "wangchuan";
//String public = "wangchuan";
String ahello = "wangchuan";
}
}
数据类型
-
强类型语言(Java)
- 要求变量的使用要求严格符合规定,所有变量都必须先定义后才能使用(安全性高,速度低)
-
弱类型语言(VB、JS)
- 要求变量的使用要求符合规定(安全性低,速度高)
-
Java的数据类型分为两大类
- 基本类型(primitive type)
- 数值类型
- 整数类型(byte1个字节、short2个字节、int4个字节、long8个字节)
- 浮点类型(float4个字节、double8字节)
- 字符类型(char2个字节)
- Boolean类型:占1位true or false
- 数值类型
- 引用类型(reference type)
- 类
- 接口
- 数组
- 基本类型(primitive type)
public class demo02 {
public static void main(String[] args) {
String a = "hello";//string是字符串
int num = 10;//int为整形
System.out.println(a);
System.out.println(num);
//八大基本数据类型
//整数
int num1 = 10; //最常用
byte num2 = 20;
short num3 = 30;
long num4 = 30L; //long类型要在数字后面加个L
//小数:浮点数
float num5 = 50.1F;
Double num6 = 3.14159268478457;
//字符
char name = '王';
//字符串,string不是关键字,类
String name1 = "王川";
//布尔值:是非
boolean flag = true;
//boolean flag = false;
}
}
浙公网安备 33010602011771号