当容器增加一定程度会有内存溢出,所以应该加个缓冲区!查询的记录有图片或者记录数量大的时候
int a(int i)
{ return i; } String a(int i) { return String.valueOf(i); }在华三面试曾遇到这样的一个问题,返回值类型不一样,问是否重载!出题人真不到如何考虑,这明显是编译不通过
String s1 = "1234"; String s2 = "1234"; String s3 = new String("5678"); String s4 = new String("5678");【new 是一个对象,常量池里有一个就一个对象】
首先第一步 String = "1234";时在字符串池中创建了一个1234的对象,指向;//这里创建了一个对象 第二步 String s2 ="1234";是先到字符串池中去找,池中有一个1234的对象,直接指向s2;//这里用的是已经有的对象所以并没有重新创建对象,目前还是创建一个对象 第三部 String = new String ("5678");这里创建了两个对象,千万别想错了,是两个,不是1个,首先在字符串池中创建一个5687的对象,之后再队内存中创建一个String对象,再把5678对象赋值给String对象//这里是两个对像,楼上的全错了不要被误导. public String(String original) { this.value = original.value; this.hash = original.hash; } 这是String带参数的,需要传一个String对象进行值和hashcode的复制,所以是两个 第四部 String = new String ("5678");到字符串池中找,存在5678对象,再在堆中创建一个新的String对象再把5678复制给新的String对象//由于字符串池中有5678不需要在创建新的了,所以这里只创建了一个对象
public class Example {
String string = "good"; private char[] a = { 'a', 'b', 'c', 'd' }; static int a1[]=new int [10]; static boolean foo(char a){System.out.print(a);return true;} public static void main(String[] args) { Example example = new Example(); example.exchange(example.string, example.a); System.out.println(example.string); System.out.println(example.a); System.out.println(a1[0]); int i=0; for (foo('A'); foo('B')&&i<2;foo('C')) { i++; foo('D'); } }public void exchange(String tString, char[] a) {
tString = "adsa"; a[0] = 'k'; }}赋值了一个引用过去,至于good是一个对象,数组是传值
for循环执行的具体顺序
Integer a = 1, b = 2, c = 3, d = 3, e = 128, f = 128; Long g = 3L; System.out.println(c == d); System.out.println(e == f); System.out.println(c == a + b); System.out.println(c.equals(a + b)); System.out.println(g.equals(a + b));
System.out.println(e.equals(c*44));
所以在业务判断时最好使用equals判断
int i=6; do { System.out.println(i); } while (i-->5); System.out.println("aa");
这种代码过段时间就不是很确定了