Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How do i initialize/fill my 2-D array?

$
0
0
Hi, this is a homework problem. I do not understand how to fill each column separatly. There are 24 rows and two columns. The left column is supposed to hold multiples of pi/2, and the right column is supposed to hold the tan of the multiple. Here is my coding, it fills both columns with multiples of pi/2. I am a beginner so the simplest answers are appreciated, thank you :)
public class ArrayFunc {

	[public static void main(String[] args) {
		double [][] array = new double[24][2];
	
	    for(int i=0; i<24; i++){
		for(int j =0; j<2; j++){
		
		array[i][j] = (i*(Math.PI/2)) ;
		
		  
			 System.out.print(array[i][j] + "\t");
		}
		System.out.println();
			         
}
}

}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>