标签:java java学习 import public hold
开始java学习,hold on!!
import java.util.ArrayList;
import java.util.Iterator;
public class Test01
{
public static void main(String []args)
{
ArrayList<String>list =new ArrayList<String>();
list.add("Hello");
list.add("World");
list.add("HaHa,,,xixi....");
for(String str:list)
{
System.out.println(str);
}
System.out.println("Second way:");
String []strArray=new String[list.size()];
list.toArray(strArray);
/*
for(int i=0;i<strArray.length;i++)
{
System.out.println(strArray[i]);
}
*/
for(String str:strArray)
{
System.out.println(str);
}
System.out.println("Iterator:");
Iterator<String>ite=list.iterator();
while(ite.hasNext())
{
System.out.println(ite.next());
}
}
}
2.algorithms:
最大公约数
public class Gcd1
{
public static int gcd(int p,int q)
{
if(q==0)return p;
int r=p%q;
return gcd(q,r);
}
public static void main(String []args)
{
System.out.println("Great common divisor:"+gcd(7,12));
}
}
本文出自 “书画插剪工匠” 博客,请务必保留此出处http://loyalbird.blog.51cto.com/6420155/1901193
标签:java java学习 import public hold
原文地址:http://loyalbird.blog.51cto.com/6420155/1901193