摘要:
public class Demo04 { public static void main(String[] args) { //实际参数和形式参数的类型要对应 int add = Demo04.add(1,2); System.out.println(add); } public static i 阅读全文
posted @ 2022-10-12 16:56
江江要努力
阅读(22)
评论(0)
推荐(0)
摘要:
public class Demo03 { public static void main(String[] args) { int a = 1; System.out.println(a);//1 Demo03.change(a); System.out.println(a);//1 } //返回 阅读全文
posted @ 2022-10-12 16:55
江江要努力
阅读(17)
评论(0)
推荐(0)
摘要:
import java.io.IOException;//Demo01类public class Demo01 { //main方法 public static void main(String[] args) { } /* 修饰符 返回值类型 方法名(...){ //方法体 return 返回值; 阅读全文
posted @ 2022-10-12 16:54
江江要努力
阅读(20)
评论(0)
推荐(0)
摘要:
public class Dome02 { public static void main(String[] args) { //逻辑运算符 boolean a = true; boolean b = false; System.out.println("a && b:"+(a&&b));//逻辑与 阅读全文
posted @ 2022-10-12 16:48
江江要努力
阅读(32)
评论(0)
推荐(0)
摘要:
public class Demo01 { public static void main(String[] args) { //自增++ 自减-- 一元运算符 int f = 3; int g = f++;//执行完这行代码后,先给g赋值,再自增 //f = f + 1; System.out.p 阅读全文
posted @ 2022-10-12 16:47
江江要努力
阅读(38)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo03 { public static void main(String[] args) { //输入多个数字,并求其总和与平均数,没输入一个数字用回车确认,通过输入非数字来结束输入并输出执行结果 Scanner sc 阅读全文
posted @ 2022-10-12 16:46
江江要努力
阅读(148)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo02 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //从键盘接收数据 int i = 0; 阅读全文
posted @ 2022-10-12 16:45
江江要努力
阅读(35)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo01 { public static void main(String[] args) { //创建一个扫描器对象,用于接收键盘数据 Scanner scanner = new Scanner(System.in); 阅读全文
posted @ 2022-10-12 16:44
江江要努力
阅读(32)
评论(0)
推荐(0)
摘要:
public class Demo08 { public static void main(String[] args) { //打印三角形 for (int i = 1; i <= 5; i++) { for(int j = 5;j >= i;j--){ System.out.print(" ") 阅读全文
posted @ 2022-10-12 16:42
江江要努力
阅读(22)
评论(0)
推荐(0)
摘要:
public class Demo07 { public static void main(String[] args) { //打印101-150之间的所有质数 //质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数 int count = 0; //不建议使用!!!! oute 阅读全文
posted @ 2022-10-12 16:42
江江要努力
阅读(30)
评论(0)
推荐(0)
摘要:
public class Demo06 { public static void main(String[] args) { //break语句用于强行退出循环,不执行循环中剩余的语句。(break语句也在swith语句中使用) //continue语句用在循环语句体中,用于终止某次循环过程,即跳过 阅读全文
posted @ 2022-10-12 16:41
江江要努力
阅读(33)
评论(0)
推荐(0)
摘要:
public class Demo05 { public static void main(String[] args) { /*计算0-100之间的奇数和偶数的和 int oddSum = 0; int evenSum = 0; for (int i = 0; i <= 100; i++) { i 阅读全文
posted @ 2022-10-12 16:40
江江要努力
阅读(38)
评论(0)
推荐(0)
摘要:
public class Demo03 { public static void main(String[] args) { //少部分情况需要一直执行,比如服务器的请求响应监听等 //循环条件一直为true就会造成死循环(无限循环)应避免这个情况出现 /*输出1-100 int i = 0; wh 阅读全文
posted @ 2022-10-12 16:38
江江要努力
阅读(34)
评论(0)
推荐(0)
摘要:
public class Demo04 { public static void main(String[] args) { //for循环语句是综测迭代的一种通用结构,是最有效最灵活的循环结构 int a = 1;//初始化条件 while(a<=100){//条件判断 System.out.pr 阅读全文
posted @ 2022-10-12 16:37
江江要努力
阅读(98)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo02 { public static void main(String[] args) { //case 穿透(故每个语句后都要加break) switch 匹配一个具体的值 /*JDK7新特性,表达式结果可以是字符 阅读全文
posted @ 2022-10-12 16:36
江江要努力
阅读(19)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo01 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println(" 阅读全文
posted @ 2022-10-12 16:35
江江要努力
阅读(33)
评论(0)
推荐(0)
摘要:
public class Demo05 { //递归思想(调用自身),数量大的话,不用这个 public static void main(String[] args) { System.out.println(f(5)); } public static int f(int n){ if (n== 阅读全文
posted @ 2022-10-12 16:33
江江要努力
阅读(28)
评论(0)
推荐(0)
摘要:
public class Demo04 { //在方法声明中,在指定参数类型后加一个省略号... //一个方法只能指定一个可变参数,它必须是方法的最后一个参数,任何普通的参数必须在它之前声明 public static void main(String[] args) { //调用可变参数的方法 p 阅读全文
posted @ 2022-10-12 16:33
江江要努力
阅读(29)
评论(0)
推荐(0)
摘要:
public class Demo02 { public static void main(String[] args) { double max = max(10,30); System.out.println(max); } //比大小int public static int max(int 阅读全文
posted @ 2022-10-12 16:26
江江要努力
阅读(29)
评论(0)
推荐(0)
摘要:
public class Demo01 { //main方法 public static void main(String[] args) { //实际参数:实际调用传递给它的参数 int sum = add(1, 2); System.out.println(sum); test(); //mai 阅读全文
posted @ 2022-10-12 16:24
江江要努力
阅读(37)
评论(0)
推荐(0)
摘要:
import java.util.Arrays;public class Demo07 { public static void main(String[] args) { int[] a = {1,5,8,3,22,13}; int[] sort = sort(a);//调用完自己写的排序方法后, 阅读全文
posted @ 2022-10-12 16:14
江江要努力
阅读(43)
评论(0)
推荐(0)
摘要:
public class Demo08 { public static void main(String[] args) { //创建一个二维数组5*5 int[][] array1 = new int[5][5]; array1[1][2] = 1; array1[2][2] = 3; //输出原 阅读全文
posted @ 2022-10-12 16:14
江江要努力
阅读(22)
评论(0)
推荐(0)
摘要:
import java.util.Arrays;public class Demo06 { public static void main(String[] args) { int[] a = {1,2,5555,674,22}; //System.out.println(a); //打印数组元素 阅读全文
posted @ 2022-10-12 16:13
江江要努力
阅读(34)
评论(0)
推荐(0)
摘要:
public class Demo05 { public static void main(String[] args) { /*[5][2] 面对对象 1,2 array[0] 2,3 array[1] 3,4 array[2] 4,5 array[3] 5,6 array[4] */ int[] 阅读全文
posted @ 2022-10-12 16:11
江江要努力
阅读(36)
评论(0)
推荐(0)
摘要:
public class Demo04 { public static void main(String[] args) { int[] arrays = {1, 2, 3, 4, 5, 6}; /*JDK1.5:没有下标 for (int array : arrays) {//array.for 阅读全文
posted @ 2022-10-12 16:01
江江要努力
阅读(34)
评论(0)
推荐(0)
摘要:
public class Demo03 { public static void main(String[] args) { int[] arrays = {1,2,3,4,5,6}; //打印全部的数组长度 for (int i = 0;i < arrays.length;i++){ System 阅读全文
posted @ 2022-10-12 15:58
江江要努力
阅读(27)
评论(0)
推荐(0)
摘要:
public class Demo01 { //变量的类型 变量的名字 = 变量的值; //数组类型 public static void main(String[] args) { int[] nums;//1声明一个数组, (数组并不存在) nums = new int[5];//2创建一个数组 阅读全文
posted @ 2022-10-12 15:57
江江要努力
阅读(117)
评论(0)
推荐(0)
摘要:
public class HelloWorld { //psvm快捷词,单行注释 public static void main(String[] args) { //sout输出一个HelloWorld! System.out.println("com.jiang.base.HelloWorld! 阅读全文
posted @ 2022-10-12 15:47
江江要努力
阅读(52)
评论(0)
推荐(0)
摘要:
public class Demo04 { //类变量 static static double salary = 2500; //属性:变量 /* 实例变量:从属于对象,如果不自行初始化,则输出这个类型的默认值0 0.0 u0000 布尔值:默认是false 除了8种基本类型,其余的默认值都是nu 阅读全文
posted @ 2022-10-12 15:45
江江要努力
阅读(48)
评论(0)
推荐(0)
摘要:
public class Demo03 { public static void main(String[] args) { int i = 128; byte b =(byte)i;//内存溢出,数值异常(byte只能到127) double c =i; /*byte,short,char >in 阅读全文
posted @ 2022-10-12 15:41
江江要努力
阅读(61)
评论(0)
推荐(0)
摘要:
public class Demo02 { public static void main(String[] args) { //整数拓展 进制 二进制0b 十进制 八进制0 十六进制0x int i1=12; int i2=012;//八进制0 int i3=0x12;//十六进制0x 0-9 A 阅读全文
posted @ 2022-10-12 15:38
江江要努力
阅读(58)
评论(0)
推荐(0)
摘要:
public class Demo01 { public static void main(String[] args) { //字符 char name='国'; //字符串,string不是关键字是类 String a="hello"; //整数 int num1=15;//4字节,最常用,-2 阅读全文
posted @ 2022-10-12 15:36
江江要努力
阅读(29)
评论(0)
推荐(0)
浙公网安备 33010602011771号