
重启JAVA
老桃子一号
这个作者很懒,什么都没留下…
展开
-
剑指Offer 38.字符串的排列 回溯 Java
剑指Offer 38.字符串的排列输入一个字符串,打印出该字符串中字符的所有排列,不能重复示例:输入 s = “abc”输出 [“abc”, “acb”, “bac”, “bca”, “cab”, “cba”]import java.util.HashSet;import java.util.LinkedList;import java.util.List;class Solution { List<String> result = new LinkedList<原创 2021-06-22 11:35:04 · 126 阅读 · 0 评论 -
重启JAVA——方法可变参数
·方法可变参数public class test { public static void main(String[] args) { System.out.println(fun(new int[]{1,2,3,4,5})); System.out.println(fun(1,2,3,4,5)); } static int fun(int ... array) { int temp = 0; for(int i :原创 2020-09-20 16:14:52 · 86 阅读 · 0 评论 -
重启JAVA——数组拷贝
·利用系统给的方法进行数组的拷贝System.arraycopy(源数组,起始点,目标数组,起始点,拷贝长度);public class test { public static void main(String[] args) { int data [] = new int[] {0,0,0,0,0,0}; int data_2 [] = new int[] {1,2,3,4,5,6}; System.arraycopy(data_2,1,da原创 2020-09-20 16:06:21 · 98 阅读 · 0 评论 -
重启JAVA——经典冒泡排序
·经典冒泡排序public class test { public static void main(String[] args) { int data [] = new int[] {1,4,3,3,2,2,3}; for(int i = 0;i < data.length;i++) { for(int j = 0;j < data.length - i - 1;j++) { if(data[j]原创 2020-09-20 15:35:02 · 91 阅读 · 0 评论 -
重启JAVA——foreach输出
·foreach输出public class test { public static void main(String[] args) { int data [] = new int[] {1,4,3,3,2,2,3}; for(int temp : data) { //自动循环,将data的每一个内容交给temp System.out.println(temp); } }}...原创 2020-09-20 15:04:18 · 97 阅读 · 0 评论 -
重启JAVA——数组的静态初始化
·数组的静态初始化public class test { public static void main(String[] args) { int a [] = new int[]{1,2,3,4,5}; int b [][] = new int[][]{{1,2,3},{4,5,6}}; for(int i = 0;i < a.length;i++) { System.out.println("a[" + i + "]原创 2020-09-20 14:45:33 · 110 阅读 · 0 评论 -
重启JAVA——构造块
·构造块public class test { public static void main(String arg[]) { Student a = new Student("1111 1111" , "a"); Student b = new Student("2222 2222" , "b"); Student c = new Student("3333 3333" , "c"); }}class Student { pr原创 2020-09-05 17:27:23 · 91 阅读 · 0 评论 -
重启JAVA——static关键字
·static关键字public class test { public static void main(String arg[]) { System.out.println(Student.school); //static属性(或方法)可以在不进行实例化对象的时候使用 //static方法只能调用static方法,非static方法能调用static方法和非static方法 Student student = new Student("1111原创 2020-09-05 17:13:40 · 213 阅读 · 0 评论 -
重启JAVA——this调用本类的构造函数
·this调用本类的构造函数public class test { public static void main(String arg[]) { Student a = new Student(); Student b = new Student("1111 1111"); Student c = new Student("2222 2222" , "c"); }}class Student { private String原创 2020-09-05 11:45:23 · 481 阅读 · 0 评论 -
重启JAVA——“+”特殊情况
·“+”特殊的拼接时刻public class HelloWorld{ public static void main(String[] args) { int a = 1; int b = 2; String result = "结果为:" + a + b; System.out.println(result); }}原创 2020-09-01 11:11:31 · 83 阅读 · 0 评论 -
重启JAVA——数据越界
·int类型越界问题public class HelloWorld{ public static void main(String[] args) { int max = Integer.MAX_VALUE; System.out.println(max); System.out.println(max + 1); //越界的话会进入循环 System.out.println(max + 1L); //在一个常量之后加上一个L转成了原创 2020-09-01 10:43:14 · 115 阅读 · 0 评论