zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    Windows系统结构
    Windows系统基本概念
    基本NT式驱动代码结构
    数据切割
    虚函数
    基类和派生类:谈继承
    jQuery简单的上拉加载
    检测是否为数组
    倒计时案例分析
    获得总的毫秒数
  • 原文地址:https://www.cnblogs.com/asenyang/p/15437109.html
Copyright © 2011-2022 走看看