• C#与Java的长度计算API的区别


    C#:

     1 public class demo01
     2     {
     3         public void test01()
     4         {
     5             //数组的长度是.Length
     6             int[] ary = new int[] { 1, 2, 3 };
     7             Console.WriteLine(ary.Length);
     8 
     9             //字符串的长度是.Length
    10             string str = "abc";
    11             Console.WriteLine(str.Length);
    12 
    13             //List的长度是.Count
    14             List<int> list = new List<int>();
    15             Console.WriteLine(list.Count);
    16 
    17             //Set的长度是.Count
    18             HashSet<string> set = new HashSet<string>();
    19             Console.WriteLine(set.Count);
    20 
    21             //Dictionary的长度是.Count
    22             Dictionary<string, int> dic = new Dictionary<string, int>();
    23             Console.WriteLine(dic.Count);
    24         }
    25     }

    Java:

     1 public class demo01 {
     2     public static void main(String[] args) {
     3         //数组的长度是.length
     4         int[] ary = new int[] {1,2,3};        
     5         System.out.println(ary.length);
     6         
     7         //字符串的长度是.length()
     8         String str = "abc";
     9         System.out.println(str.length());
    10         
    11         //List的长度是.size()
    12         List<Integer> list = new ArrayList<Integer>();
    13         System.out.println(list.size());
    14         
    15         //Set的长度是.size()
    16         Set<String> set = new HashSet<>();
    17         System.out.println(set.size());
    18         
    19         //Map的长度是.size()
    20         Map<String, Integer> map = new HashMap<String, Integer>();
    21         System.out.println(map.size());
    22     }
    23 }
  • 相关阅读:
    DOM_节点操作创建表格
    表单提交
    HTML常用标签
    网络通讯详解
    java===TCP(多线程多客户端同时上传字节数据:图片为例)
    java===TCP(文件上传功能)
    java===UDP
    java==IO=随机读写文件
    git中的基本命令
    ansible中roles的简单使用
  • 原文地址:https://www.cnblogs.com/asenyang/p/15437109.html
Copyright © 2020-2023  润新知