2017-08-23 10:38:01 writer:pprp package test; import java.util.*; public class test2 { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("welcome to test2"); //记住数组初始化应该这样 int[] d = new int[]{1,2,3,4}…
2017-08-22 21:23:37. writer:pprp package test; public class helloWorld { int maxn = 123; //常量,需要定义一个对象调用 final int MAX = 20; //类常量,不需要再定义一个对象来调用 static final int MIN = -100; public static void main(String[] args) { // TODO Auto-generated method stub…
一.选择题(每题2分,共40分) 1.下面哪个是Java语言中正确的标识符(C ) a) 3com b)import c)that d)this 2.下面哪个语句(初始化数组)是不正确的: ( B ) a) Int x[]={1,2,3} b)int x[3]={1,2,3} C) String[] x=new String[]{“a”,”c”} d) int x[]=new int[]{1,2,3}; 3.…
一:String类 1.String对象的初始化 由于String对象特别用,所以在对String对象进行初始化时,Java提供了一种简化的特殊语法,格式如下: String s = "abc"; s = "Java语言"; 其实按照面向对象的标准语法,其格式应该为: String s = new String("abc"); s =new String("Java语言"); 只是按照面向对象的标准语法,在内存使用上存在比较大…
string是我们经经常使用到的一个类型,事实上有时候认为敲代码就是在重复的操作字符串,这是C的特点,在java中.jdk非常好的封装了关于字符串的操作.三个类String .StringBuffer . StringBuilder .这三个类基本上满足了我们在不同情景下使用字符串的需求. 一.String JDK的解释是 "Strings are constant; their valuescannot be changed after they are created"也就是说St…
原文:分享非常有用的Java程序 (关键代码) (二)---列出文件和目录 File dir = new File("directoryName"); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; i < children.length; i++) { // Get f…
String String是不可变的 我们都知道String不是基本数据类型,而是一个对象,并且是final类型的,不可变的.(public final class String) 查看以下代码: String text = "a"; text = "b"; String不是不可变的么?为什么可以这样用?因为text是字符串"a"的引用,即引用是可以变化的,跟对象实例的属性变化没有关系.(这里创建的是两个String对象) String设计成不可…