importjava.util.Scanner;
/*求两个字符串的最长公共子串*/
publicclassstringDemo{
publicstaticvoidmain(String[]args){
Scannerscanner=newScanner(System.in);
System.out.println("请输入第一个字符串:");
Stringstr1=scanner.nextLine();
System.out.println("请输..
分类:
其他好文 时间:
2014-12-05 19:31:50
阅读次数:
131
1、对ArrayList的遍历出的错误 public void setOtherWeekRep(ArrayList owrList) { Iterator iter = owrList.iterator(); while(iter.hasNext()){ System.out.println...
分类:
其他好文 时间:
2014-12-05 19:04:06
阅读次数:
148
public class UserAction { private String name; private int age; public String add(){ System.out.println(name+age); return "...
分类:
其他好文 时间:
2014-12-05 16:49:57
阅读次数:
173
你有一段代码可以被组织在一起并独立出来
讲这段代码放在一个独立函数中,并让函数名称解释该函数的用途
范例:无局部变量
void printOwing(double amount){
printBanner();
//printDetail
System.out.println("name:"+_name);
System.out.println("amount:"+amount);
...
分类:
其他好文 时间:
2014-12-05 12:49:34
阅读次数:
122
不废话,先上代码:ArrayList col = new ArrayList(); System.out.println("Initial size: " + col.size()); for(int i = 0; i 里的类型是Integer,我传入一个int的应该可以自动实现autoboxi.....
分类:
其他好文 时间:
2014-12-05 12:10:44
阅读次数:
142
public class Main { { //构造块(在构造对象时调用,先于构造方法执行) System.out.println("我是构造块!"); } static{ //静态块(在类加载时执行,且只执行一次【在构造块前执行】eg:数据库连接) S...
分类:
编程语言 时间:
2014-12-03 22:44:57
阅读次数:
153
java中分割字符串使用是String类的静态方法split方法,例如:
@org.junit.Test
public void splitTest(){
String str = "aaa,bbb,ccc";
String[] strs = str.split(",");
System.out.println(strs.length);
for(int i = 0;i<str...
分类:
编程语言 时间:
2014-12-03 12:36:46
阅读次数:
175
valhello="HelloWorld"
println(hello)
//函数声明
defmin(x:Int,y:Int):Int={
vara=x
if(x>y)a=y
returna
}
//===>
println("min:"+min(3,5))//3
//表达式函数声明
defmax(x:Int,y:Int):Int=if(x>y)xelsey
//===>
println("max:"+max(5,8))//8
//while循..
分类:
其他好文 时间:
2014-12-03 10:38:41
阅读次数:
139
最近工作中,经常需要比较2个对象的值。有个问题经常遇到,就是下面的2种情况。 public static void main(String[] args) { Integer a =11; Object b=a; System.out.println(b.equals("11"));//false String c ="11"; Object d = c; Syste...
分类:
编程语言 时间:
2014-12-02 16:40:11
阅读次数:
161
publicclasssushu{ publicstaticvoidmain(String[]args){ inti,m=1000; intcount=0; for(i=1;i<=m;i++){ if(prime(i)){ count++; System.out.print(i+""); if(count%10==0){ System.out.println(); } } } System.out.println();System.out.println("1-100..
分类:
其他好文 时间:
2014-12-02 15:27:49
阅读次数:
156