| | |
searching an array
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
never really used 2d arrays, but when I did (as a student) I took the easy way:
Java Syntax (Toggle Plain Text)
public class SearchChar { public static void main(String args[]){ char toFind = 'a';// determin the char you want; char[][] array2d = {{'1','k','d'},{'a','p'}};//a given array int a = -1; int b = -1; System.out.println("eerste lengte: " + array2d.length); System.out.println("tweede lengte: " + array2d[0].length); for ( int i = 0; i < array2d.length; i++){ System.out.println("i = " + i); for ( int j = 0; j < array2d[i].length; j++){ char test = array2d[i][j]; if (test == toFind){ a = i; b = j; } } } System.out.println("a : " + a + " b : " + b); } }
![]() |
Similar Threads
- Fastest way to search the table ( or array ) (C++)
- Searching an array (Java)
- Searching array problems (C++)
- using boolean expression on an array (Java)
- mySQL database searching for registration (MySQL)
Other Threads in the Java Forum
- Previous Thread: need help for clarifications
- Next Thread: Collision Detection - Micro Java
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class classes client code component css csv database eclipse ee error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javaee javaprojects jmf jni jpanel julia jvm key linked linux list loan loop map method methods mobile netbeans newbie objects oriented output panel phone print printf problem program programming project projects recursion replaydirector reporting researchinmotion robot rotatetext scanner screen se server service set size sms software sort sql string swing test threads transfer tree ubuntu windows





