import java.lang.String; import java.util.Scanner; public class Main { public static void main(String[] args) { //方式一:会创建两个字符串对象(会在字符串常量池中也存一份) String a = new String("dining1"); //[尽量使用这种方式]方式二:最多创建一个字符串对象.(在字符串常量池中找有没有,有则直接指过去,否则创建,然后指过去.) Stri
1.String类注释说明 /** * The {@code String} class represents character strings. All * string literals in Java programs, such as {@code "abc"}, are * implemented as instances of this class. * <p> * Strings are constant; their values cannot be ch
上一篇文章学习了IL的入门,接下来我们再通过两个例子来了解下类的属性.构造函数以及接口的使用 一.类的属性.构造函数 1.先看下我们要构建的类的C#代码,然后再进行IL的实现,示例代码如下: [Serializable] public class Dynamic { ; public const string ConstField = "const"; /// <summary> /// 定义属性 /// </summary> public int A { ge
一.String类的方法 public char charAt(int index) 返回字符串index个字符 public int length() 返回字符串长度 public int indexof(String str) 返回字符串中出现str的第一个位置 public int indexof(String str, int fromIndex) 返回字符串中从fromIndex开始出现str的第一个位置 public bool
1.subString()方法的作用 subString(int beginIndex, int endIndex)方法的返回的是以beginIndex开始到 endIndex-1结束的某个调用字符串. String x = "abcdef"; x = x.substring(1,3); System.out.println(x); 输出结果: bc 2.JDK6中的subString()方法 String类实现是使用到了char数组.在JDK6里面String类有三个属性char v
String是一个对象 String不属于8种基本数据类型(byte, char, short, int, float, long, double, boolean),String是对象,所以其默认值是null. String是一种特殊的对象,有其它对象没有的一些特性,通过JDK发现: public final class String implements java.io.Serializable, Comparable<String>, CharSequence { /** The val