zoukankan      html  css  js  c++  java
  • Java知识点

    线程

    1、Runnable和Callable的区别?

     callable与runnable相比,callable可以有返回值,返回值通过FutureTask进行封装。

    2、run()方法和start()方法的区别?

     run()是在主进程中运行,直接运行相当于一个普通函数;而start()方法可启动线程,可以并发执行。

    3、有几种线程池?

     主要有三种。

     1)CachedThreadPool:一个任务创建一个线程;

     2)FixedThreadPool:所有任务只能使用固定大小的线程;

     3)SingleThreadExecutor:相当于大小为 1 的 FixedThreadPool。

    集合

    1、HashSet和TreeSet有什么区别?

     1)HashSet是由哈希表实现的,而TreeSet是由二叉树实现的;

     2)HashSet是无序的,而TreeSet是自动排好序的;

     3)HashSet能存放null值,且只能存放一个,而TreeSet不能存放null值;

     4)HashSet要求放入的对象必须实现HashCode()方法。

    2、HashMap能存放Null值吗?

     HashMap的键和值都能存放null,键只能有一个为null,值可以多个对应为null;

     (HashTable的键和值都不能存放null,且是线程安全的)。

    3、ArrayList如何使用线程安全?

     1)使用synchronized关键字;

     2)使用Collections.synchronizedList(); 例如:

    List<Map<String,Object>> data=Collections.synchronizedList(new ArrayList<Map<String,Object>>());

     

    Spring

    1、@RestController与@Controller的区别?

     1)@RestController = @RequestBody + @Controller;

     2)如果需要返回页面,需要使用@Controller;返回数据,使用@RestController。

    2、@RequestMapping如何转换成@GetMapping?

     @RequestMapping(method = RequestMethod.GET)。

    3、@Configuration和@Component区别?

     @Configuration包括@Component,@Configuration修饰的类被定义为一个Spring容器,里边可以配置很多Bean。

    IO流

    1、字节流如何转为字符流?

        https://blog.csdn.net/qq_40856560/article/details/81808641

  • 相关阅读:
    0714买卖股票的最佳时机含手续费 Marathon
    0070爬楼梯 Marathon
    0045跳跃游戏II Marathon
    0343整数拆分 Marathon
    0406根据身高重建队列 Marathon
    0096不同的二叉搜索树 Marathon
    0763划分子母区间 Marathon
    0435无重叠区间 Marathon
    0452用最少数量的箭引爆气球 Marathon
    0509斐波那契数 Marathon
  • 原文地址:https://www.cnblogs.com/liuyu666/p/13859806.html
Copyright © 2011-2022 走看看