重庆代孕价格 -首页

重庆代孕█微信:138-0226370█重庆代孕价格多少█微信:138-0226-9370█重庆代孕费用多少█微信:138-0226-9370█

1、JDK的版本

(1)    jdk1.7常见的新特性

①    switch支持String(原本只支持byte、short、char、int)

(2)    Jdk1.8常见的新特性(myelipse10/2014不支持jdk1.8)

①    使用default修饰词为接口添加非抽象方法

1.    public interface NewCharacter {  

2.          

3.        public void test1();  

4.          

5.        public default void test2(){  

6.            System.out.println("我是新特性1");  

7.        }  

8.      

9.    } 

②    添加了lambda表达式(常用的使用方式 (x,y) ->System.out.println(x+","+y); )

③    添加了foreach方法

④    添加了stream方法(以下为②③④综合例子)

1.    public class StreamExample {  

2.      

3.        public static void main(String[] args) {  

4.      

5.            List<Integer> myList = new ArrayList<>();  

6.            for(int i=0; i<100; i++) myList.add(i);  

7.      

8.            //有序流  

9.            Stream<Integer> sequentialStream = myList.stream();  

10.      

11.            //并行流  

12.            Stream<Integer> parallelStream = myList.parallelStream();  

13.      

14.            //使用lambda表达式,过滤大于90的数字  

15.            Stream<Integer> highNums = parallelStream.filter(p -> p > 90);  

16.            //lambdag表达式 forEach循环  

17.            highNums.forEach(p -> System.out.println("最大数 并行="+p));  

18.      

19.            Stream<Integer> highNumsSeq = sequentialStream.filter(p -> p > 90);  

20.            highNumsSeq.forEach(p -> System.out.println("最大数 有序="+p));  

21.      

22.        }  

23.      

24.    } 

输出结果

1.    最大数 并行=91  

2.    最大数 并行=96  

3.    最大数 并行=93  

4.    最大数 并行=98  

5.    最大数 并行=94  

6.    最大数 并行=95  

7.    最大数 并行=97  

8.    最大数 并行=92  

9.    最大数 并行=99  

10.    最大数 有序=91  

11.    最大数 有序=92  

12.    最大数 有序=93  

13.    最大数 有序=94  

14.    最大数 有序=95  

15.    最大数 有序=96  

16.    最大数 有序=97  

17.    最大数 有序=98  

18.    最大数 有序=99 

https://blog.csdn.net/dounine/article/details/70546625

2、基本数据类型和运算过程

(1)    八大基本数据类型:byte(1字节),short(2字节),int(4字节),long(8字节).float(4字节),double(8字节),char,boolean(1位)(1字节=8位)

char的字节:

char使用unicode存储字符,如果是utf-16,则为2字节,如果是utf-8,则为1到4字节,中文一般为3字节

(2)    赋值、算术、关系、逻辑、位运算、条件运算

①    自增,自减

int a = 1;

int sum = (a++) + (++a) + (a--) + (++a) + (a++) + (--a) + (a++);//19

②    &和&&的区别

都可以做逻辑运算符,&无论第一个表达式是否为true,都会判断第二个表达式,&&当第一个表达式是false,则第二个表达式不会判断,&还可以做位运算符

③    运算符的优先级
算术>关系>逻辑
+- >< &!|

3、枚举

1.     public enum EnumDemo {  

2.        SPRING(1, "春季"), SUMMER(2, "夏季"), AUTUMN(3, "秋季"), WINTER(4, "冬季");  

3.      

4.        private final int code;  

5.        private final String value;  

6.      

7.        private EnumDemo(int code, String value) {  

8.            this.code = code;  

9.            this.value = value;  

10.        }  

11.      

12.        public static void show() {  

13.            System.out.println("枚举的键\t枚举的值\t枚举的名字\t枚举的下标");  

14.            for (EnumDemo enumDemo : EnumDemo.values()) {  

15.              System.out.print(enumDemo.code+"\t");  

16.              System.out.print(enumDemo.value+"\t");  

17.              System.out.print(enumDemo.name()+"\t");  

18.              System.out.println(enumDemo.ordinal());  

19.            }  

20.        }  

21.    }

https://blog.csdn.net/jaafar_1024/article/details/76242205

4、String

(1)    String常用方法

来自慕课网

①    ==和equals的区别

如果没有重写equals方法==和equals都是比较地址,重写了equals方法则equals方法比较的是对应地址的值,基本数据类型使用==比较,java中String和包装类默认重写了equals方法。

(2)    StringBuilder(速度快) 或 StringBuffer(线程安全)

Reverse方法:倒序,在原有的基础上倒序,无返回值

①    String和StringBuilder、StringBuffer三者的区别

String是final修饰的不可变的,对String的任何改变产生一个新的String,占空间,StringBuilder和Stringbuffer是可变的,修改会在原有的基础上变动,StringBuilder线程不安全,运行速度较快,Stringbuffer线程安全,运行速度较慢。

String重写了equals方法,StringBuffer和Stringbuilder没有。

(3)    String的堆栈

常量池中一个对象,堆中三个对象,一共四个对象

https://blog.csdn.net/LK274857347/article/details/77512555

(4)    String和基本数据类型、包装类互换

①    包装类与基本数据类型自动装拆箱(int初始值为0,integer为null)

②    转化为String

提示:还可以使用对应包装类的toString方法,推荐valueOf:

效率最高,可以转化char数组、toString不行,

每种数据都是使用String不用找各种包装类的对应类,整齐

1.    int a = 1;  

2.    Integer b = 1;  

3.    char c = '1';  

4.    Character d = '1';  

5.    char[] e = { 'a', 'b', 'c' };  

6.    String string1 = String.valueOf(a);// int转化为String  

7.    String string2 = String.valueOf(b);// int包装类转化为String    

8.    String string3 = String.valueOf(c);// char转化为String    

9.    String string4 = String.valueOf(d);// char包装类转化为String  

10.    String string5 = String.valueOf(e);// char数组转化为String

③    String转化为基本数据类型和包装类

1.    String s = "1234";  

2.    // parseInt返回的是int,valueOf和构造函数返回是Integer,自动装拆箱后没有区别  

3.    Integer i1 = Integer.parseInt(s);  

4.    Integer i2 = Integer.valueOf(s);  

5.    Integer i3 = new Integer(s);  

6.    // charAt返回坐标为1对应的字符,indexOf返回符文为1对应的下标,toCharArray()返回char数组  

7.    char c1 = s.charAt(1);  

8.    char c2 = (char) s.indexOf("1");  

9.    char[] c3 = s.toCharArray();  

10.    System.out.println(c1); 

5、数组

(1)    常见方法

Arrays.

sort();升序;

equals(a,b);比较

toString(a);输出字符串

fill(a,4);所有元素换成4

copyOf(a,4);复制出一个新的数组,长度变成4

binarySeatch(a,4);查询4在数组a中下标多少

asList(list);数组转化为list

(2)    冒泡排序

for(i<N-1){for(j<N-i-1){交换位置}}

6、集合

(1)    基本知识

①    Collection、List、Set、Map都是接口无法实例对象

②    常见集合简介

1)    ArrayList有序,可重复,查询速度快,数组方式

2)    LinkedList有序,可重复,插入数据快,链表方式

3)    HashSet无序,不可重复,散列表方式

4)    HashMap无序,key不可重复,value可重复,线程不安全,效率较快,key可以有一个null

5)    HashTable无序,key不可重复,value可重复,线程安全,效率较慢,key不能为null

(2)    ArrayList(HashSet方法一样)

1.    List<String> list = new ArrayList<String>();  

2.    list.add("one");  

3.    list.add("two");  

4.    list.add("three");  

5.    list.remove("two");  

6.    boolean flag = list.contains("one");// 集合中是否存在"one"  

7.    boolean flag1 = list.isEmpty();// 集合是否为空  

8.    System.out.println(list.size());//长度为2,数组用length,String用length(),集合用size()  

9.    Iterator iterator = list.iterator();  

10.    while (iterator.hasNext()) {  

11.        System.out.println(iterator.next());// 输出one three  

12.    }  

13.    System.out.println(flag + "," + flag1);// true,false  

(3)    HashMap

1.    Map<Integer, String> map = new HashMap<Integer, String>();  

2.    map.put(1, "one");  

3.    map.put(2, "two");  

4.    map.put(3, "three");//put可以添加也可以修改  

5.    map.get(1);// 根据键得到值  

6.    Set<Integer> set = map.keySet();// 获得键的set集合  

7.    Iterator<Integer> iterator = set.iterator();  

8.    //迭代器有什么用,我感觉for更好用,求回答  

9.    while(iterator.hasNext()){  

10.        System.out.println(iterator.next());// 1 2 3  

11.    }  

12.    List<String> list = new ArrayList<String>(map.values());  

13.    //这里用迭代器报错,不知道为什么只能用for了  

14.    for(String str:list){  

15.              System.out.println(str);// one two three  

16.          } 

7、流程控制

(1)    选择结构:if else switch(){case 常量: break;}

(2)    循环结构:while do{}while(); for()

(3)    循环四个要素:开始、条件、循环体、循环退出

(4)    控制循环的关键字

①    continue:跳过一次循环

②    break:跳出循环

③    return:返回值跳出方法

④    System.exit(0):系统正常退出,1为非正常退出

8、修饰词

(1)    访问修饰符:

①    private 本类

②    默认 本包

③    protected 本包及其子类

④    public 公共的

(2)    其他修饰词

①    static 类共有的属性和方法

1)    单例模式

a.    恶汉模式

1.    public class Singleton {  

2.      

3.        private final static Singleton INSTANCE = new Singleton();  

4.      

5.        private Singleton(){}  

6.      

7.        public static Singleton getInstance(){  

8.            return INSTANCE;  

9.        }  

10.    }

b.    懒汉模式

1.    public class Singleton {  

2.      

3.        private static Singleton singleton;  

4.      

5.        private Singleton() {}  

6.      

7.        public static synchronized Singleton getInstance() {  

8.            if (singleton == null) {  

9.                singleton = new Singleton();  

10.            }  

11.            return singleton;  

12.        }  

13.    }  

c.    内部类

1.    public class Singleton {  

2.      

3.        private Singleton() {}  

4.      

5.        private static class SingletonInstance {  

6.            private static final Singleton INSTANCE = new Singleton();  

7.        }  

8.      

9.        public static Singleton getInstance() {  

10.            return SingletonInstance.INSTANCE;  

11.        }  

12.    }

②    final 修饰变量时引用不可变,值可变,修饰方法时方法不可重写,修饰类时方法不能被继承

//finally异常处理的一部分,除了System.exit(0/1)必被执行

//finalize类被垃圾收集器回收时执行的方法

③    synchronized 线程同步

(3)    抽象和接口

共同点:有抽象方法一定是抽象类或者接口,都不能实例对象

不同点:抽象类的修饰符没有限制,抽象类中可以有0到多个抽象方法,类继承抽象类时只能继承1个,接口的变量修饰词固定为public static final,方法固定为public abstract ,jdk1.8后可以使用default增加非抽象方法,类实现接口时可以实现多个

9、封装、继承、多态

(1)    封装

①    步骤:私有化属性,生成属性的setter/getter方法,在方法中加入限制...

②    意义:提高代码的安全性

(2)    继承

①    步骤:新建类时使用extends继承一个类,使用implements实现多个接口

②    意义:提高代码重用性

(3)    多态

①    体现:体现在方法重载和重写中,重写的返回值类型、参数必须与父类相同或者是其子类

②    意义:编程时引用对象无法确定类型,运行时才确定引用对象的类型时使用,提高代码的灵活性和扩展性

1)    重载和重写的区别

重载和重写的方法名必须相同,重载在一个类中,重写在有继承关系的两个类中

重载只与参数类型有关,参数类型或者个数必须不同

重写的访问修饰符不能严于父类,返回值类型、参数必须与父类相同或者是其子类。

重写不能抛出比父类更多的异常。

10、异常

(1)    Error是虚拟机错误、线程死锁等,程序员无法解决

(2)    Exception 分为编译异常和运行时异常

①    编译异常

②    运行时异常(RuntimeException)

//破解office2016

https://jingyan.baidu.com/article/59a015e352f275f794886598.html

//使用word上传博客

https://www.cnblogs.com/ywhyme/p/7744393.html

//第一次写博客,可能会有很多错误,望指出,看过的记得扣1,让我知道有人看过0.0

猜你喜欢

转载自www.cnblogs.com/aamayi/p/10270341.html
今日推荐