工作随笔

关于java当中size和length的使用,在工作当中,没有对size和length有一个明确的概念,总是能.出来哪一个就用哪一个。

 1 /**
 2  * .length 是数组的基本属性.
 3  * .size() 是集合的方法,集合是一个容器,用长度来形容不合适.
 4  * .length() 是字符串的方法,用于统计字符串的长度.
 5  * 只有字符串拥有.length()方法
 6  */
 7 public class Main {
 8     public static void main(String[] args) throws IOException {
 9         List<Integer> integerList = new ArrayList<>();
10         integerList.add(1);
11         integerList.add(2);
12         System.out.println("集合大小: " + integerList.size());
13         int[] score = new int[4];
14         System.out.println("数组长度: " + score.length);
15         String str = "这是一个字符串";
16         System.out.println("字符串长度: " + str.length());
17     }
18 }

 插值语法

需要处理一个几百行的超长数据,其中部分位置需要随时替换路径,从前没有使用过插值语法。

1     public static void main(String[] args) throws IOException {
2         String str1 = "java";
3         String str2 = "C#";
4         String str3 = "C++";
5         String shaderValue = String.format("这是一个插值语法%s | %s | %s", str1, str2, str3);
6         System.out.println(shaderValue);
7     }

 2023.07.23

js当中十六进制转十进制的问题,解决颜色的转化问题。

1 let hex = "ff";
2 let color = parseInt("0x" + hex);
3 console.log(color);

 

posted @ 2023-07-19 23:12  念文丶  阅读(7)  评论(0编辑  收藏  举报