public class StringListSorting { public static void main(String[] args) { List<String> myList = new ArrayList<>(); myList.add("apple"); myList.add("banana"); myList.add("orange"); myList.add("grape"); // 转换为大写形式 List<String> uppercaseList = new ArrayList<>(); for (String str : myList) { uppercaseList.add(str.toUpperCase()); } // 或者使用流式操作 // List<String> uppercaseList = myList.stream().map(String::toUpperCase).collect(Collectors.toList()); // 对转换后的列表进行排序 Collections.sort(uppercaseList); // 或者使用流式操作 // List<String> sortedList = uppercaseList.stream().sorted().collect(Collectors.toList()); System.out.println(uppercaseList); } }
9、你们Redis的使用场景,具体怎么去用
10、基于Redis做分布式锁有使用Lua脚本吗
11、两张表,一个是员工表
副表
筛选出某部门工资最高的员工的name
SELECT e.name FROM employee e INNER JOIN department d ON e.departmentId = d.departmentId WHERE d.departmentName = '目标部门名称' ORDER BY e.salary DESC LIMIT 1;
12、会用反射之类的吗
13、对数据库索引有一些优化吗
14、假如有sql比较慢,怎么去优化
15、三数之和
16、反问
public class DeadLockDemo { private static Object resource1 = new Object();//资源 1 private static Object resource2 = new Object();//资源 2 public static void main(String[] args) { new Thread(() -> { synchronized (resource1) { System.out.println(Thread.currentThread() + "get resource1"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread() + "waiting get resource2"); synchronized (resource2) { System.out.println(Thread.currentThread() + "get resource2"); } } }, "线程 1").start(); new Thread(() -> { synchronized (resource2) { System.out.println(Thread.currentThread() + "get resource2"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread() + "waiting get resource1"); synchronized (resource1) { System.out.println(Thread.currentThread() + "get resource1"); } } }, "线程 2").start(); } }
17、除了用synchronized加锁还有其他方式加锁吗
18、用ReentrantLock怎么实现
19、反问
#数字马力社招#