![]() |
Matrices
Hi,
i want to get the size of a matrix from a user at the command line and then prompt them to enter the values to be stored in the matrix, i cant wrap my head around 2d arrays (programming them, can you help me pls. thnx x10 |
If you know how to get user input, then creating a 2D array is simple enough:
:
int[][] matrix = new int[numRows][numCols];If you need more help, your best bet would be to search the web for answers. A Google search for "2d array java" turns up a multitude of resources. |
im am using stringtokenizer to tokenize the user input (first row of data), but where do i put the while(st.hasMoreTokens()) loop?, here is my code:
:
StringTokenizer st = new StringTokenizer(data);thnx x 10 |
Will you please stop rating all your threads 5 stars? The exclamation mark sign isn't necessary either. Your posts will be read.
If you expect the user to enter a specific number of tokens, a for loop would likely be preferable to a while loop. |
| All times are GMT -5. The time now is 4:57 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC