安装eclipse
安装地址:https://www.eclipse.org/downloads/packages/
选择 for javaee developers, 根据自己电脑选择正确的安装即可。
简单的配置, 新建包, 基本的快捷键设置等等, 网上的教程还是挺详细的。。。
有了IDE, 又有了在sublime Text上敲代码的感觉了哈哈
1. 运算符
1.1 算数运算符
1.1.1 加减乘除
class MathOperatorDemo{ public static void main(String[] args){ int a = 15; int b = 2; System.out.println(a+b); //17 System.out.println(a-b); //13 System.out.println(a*b); //30 System.out.println(a/b); //7, 两个 int 相运算 byte,short,char->int->long->float->double System.out.println(a%b); //1 //如果想要得到 7.5 怎么办,必须让小数运算 System.out.println(a/b*1.0); //7.0 System.out.println(1.0*a/b); //7.5 System.out.println((double)a/b); //7.5 System.out.println((double)(a/b)); //7.0 } }
1.1.2 ++和--运算
这一块是python中没有接触过的,理解了好一会儿。。
/** 单独使用++或--,效果都是+1或者-1 */ int a = 10; int b = 10;a++; // a=11 ++a; // a=11 b--; // b=9
/** 参与运算(包括赋值,打印,小括号等等) ++在前:先+1,后运算 ++在后:先运算,后+1 */ int c = 10; int d = 10; int e = c++; // e=10, c=11 int f = ++d; // f=11, d=11 c = 10; d = 10; //重新赋值 System.out.println(c++); //10 System.out.println(++d); //11
//测试 int a = 4; int b = (a++)+(++a)+(a*10) //70 /* 过程:(a++)=4, 此时a=5 (++a)=6, a=6 (a*10)=60, a=6 */
1.2 赋值运算符
=; +=; -=; *=; /=, %=
其中包含了一个默认的强制类型转换
short s = 1; s = s+1; //错误, s+1的结果是int,int赋值给short有损失 s +=1; //可以,包含的强制类型转换 s=(short)(s+1)
1.3 关系运算符
1.5 位运算符
/* 练习: 学习成绩>=90 分的同学用 A 表示, 80-89 分之间的用 B 表示, 70-79 分以下的用 C 表示, 60-69 分以下的用 D 表示, 60 以下用 E。 */ public class MathData { public static void main(String[] args) { int score =69; String result = score>=90? "A": score>80? "B":score>=70? "C":score>=60? "D":"E"; System.out.println(result); } }
2. 键盘录入
有点类似于python的imput
1. 导包: import java.util.* 或者 import java.util.Scanner
2. 创建 Scanner对象
Scanner imput = new scanner(System.in);
3. 使用相应的方法
后记
感觉起来还是和python有不少相似之处,不知道和别的汇编语言情况是不是类似呢。
可以加快一点学习速度!
原文:https://www.cnblogs.com/gzqcason/p/14800024.html