hej
hej
Posted in Text, on January 25, 2012 at 03:00
public class Randomarray {
	private int []random;
	//konstrukor
	public Randomarray(){
		random=new int[10];
		for(int i=0;i<random.length;i++)
			random [i]=(int)(Math.random()*100);
	}
		public Randomarray(int n){
				random=new int[10];
				for(int i=0;i<random.length;i++)
					random [i]=(int)(Math.random()*100);
			}

	public String toString(){
		String out="";
		for(int i=0;i<random.length;i++)
			out+=random[i]+" ";
		return out;

	}
	public int getMax(){
		int max=random[0];
		for(int i=1;i<random.length;i++)
			if (random[i]>max)
				max=random[i];
		return max;
	}
	public int getMin(){
		int min=random[0];
		for(int i=1;i<random.length;i++)
			if (random[i]<min)
				min=random[i];
		return min;
	}

}

Share this code

| More

Use the link below to share the code:
HTML
BBCode