【JAVA学习路-think in java】:调用其他的类库

package pkg2;//MUST be the first statement
import pkg.*;

public class test {
	public static void main() {
		p42 obj=new p42();	
	}
}
package pkg;
// learn about Random
import java.util.*;

public class p42 {
	
	public static void main(String[] args) {
		
		Random ran=new Random(914);
		System.out.println("ran="+ran);
		int i=ran.nextInt(20);
		int j=ran.nextInt(100);
		int k=ran.nextInt(100000);
		
		System.out.println("i="+i);
		System.out.println("j="+j);
		System.out.println("k="+k);
		
	}
	
	
}

OUTPUT:

15,2.71828,3.14,Unbelivable,
Here,you,see,six,strings,now!,9527,
pkg.a@15db9742,pkg.a@6d06d69c,
------------    CUT LINE   ------------

K=886    1 1 2 object is so 5 8 13 3.14 flexible 
K=1    2.1 2.3 4 5 abc 
------------    CUT LINE   ------------

J=100    Tom/ cat/ &/ jenny/ mouse/ 

发布了29 篇原创文章 · 获赞 5 · 访问量 6033

猜你喜欢

转载自blog.csdn.net/Andrew_Zeng/article/details/104057617
今日推荐