欢迎访问宙启技术站
智能推送

常用Java函数列表,你值得拥有!

发布时间:2023-07-01 20:44:27

1. System.out.println(String):打印字符串并换行

2. Integer.parseInt(String):将字符串转换为整数

3. Double.parseDouble(String):将字符串转换为浮点数

4. String.valueOf(Object):将对象转换为字符串

5. Math.abs(int):返回整数的绝对值

6. Math.sqrt(double):返回一个数的平方根

7. Math.pow(double, double):返回 个数的第二个数次幂

8. Math.min(int, int):返回两个整数的最小值

9. Math.max(int, int):返回两个整数的最大值

10. Math.random():返回一个0到1之间的随机数

11. String.length():返回字符串的长度

12. String.charAt(int):返回字符串中指定位置的字符

13. String.substring(int):返回从指定位置开始的子字符串

14. String.replace(CharSequence, CharSequence):将字符串中的指定字符序列替换为另一个字符序列

15. String.split(String):将字符串分割为数组

16. String.trim():去除字符串两端的空格

17. String.toLowerCase():将字符串转换为小写

18. String.toUpperCase():将字符串转换为大写

19. Arrays.toString(int[]):将整数数组转换为字符串

20. Arrays.sort(int[]):对整数数组进行升序排序

21. Arrays.binarySearch(int[], int):在已排序的整数数组中搜索指定元素,并返回其索引

22. ArrayList.add(E):向ArrayList中添加元素

23. ArrayList.get(int):获取ArrayList中指定位置的元素

24. ArrayList.remove(int):从ArrayList中删除指定位置的元素

25. ArrayList.size():返回ArrayList中的元素数量

26. LinkedList.addFirst(E):在LinkedList的开头添加元素

27. LinkedList.addLast(E):在LinkedList的末尾添加元素

28. LinkedList.getFirst():获取LinkedList的 个元素

29. LinkedList.getLast():获取LinkedList的最后一个元素

30. LinkedList.removeFirst():删除LinkedList的 个元素

31. LinkedList.removeLast():删除LinkedList的最后一个元素

32. HashMap.put(K, V):向HashMap中添加键值对

33. HashMap.get(K):获取HashMap中指定键对应的值

34. HashMap.remove(K):从HashMap中删除指定键对应的映射

35. HashMap.containsKey(K):判断HashMap中是否包含指定键

36. HashMap.containsValue(V):判断HashMap中是否包含指定值

37. HashSet.add(E):向HashSet中添加元素

38. HashSet.remove(E):从HashSet中删除指定元素

39. HashSet.contains(E):判断HashSet中是否包含指定元素

40. HashSet.size():返回HashSet中的元素数量