Results 1 to 2 of 2
  1. #1
    Fotis is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Default Search in array of objects (?)

    Hi.

    I cannot explain my question very well.
    I have an array of objects. Can i perform a search in this?

    Check the following code as example:

    Java Code:
    public class test1 {
        	public static void main (String[] args){
        	
        		test2[] array = new test2[2];
        		
        		for(int i=0;i<2;i++){
    	        array[i]=new test2(); 
        		}
    
        		int a=1, b=2;
        		String c ="c", d = "d";
        		
    	        array[0].insert(a, c);
    	        array[1].insert(b, d);    
        	}
    }
    Java Code:
    public class test2 {	
    	    int z;
    	    String y;
        public void insert(int z, String y) { 
            this.z = z; 
            this.y = y; 
        } 
    }
    I want check if int 1 (or String b) exists in array[i].
    Is it possible?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Search in array of objects (?)

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. search from array list
    By infernocy in forum New To Java
    Replies: 14
    Last Post: 04-14-2012, 04:50 PM
  2. How to convert array of Objects into array of Strings
    By elenora in forum Advanced Java
    Replies: 1
    Last Post: 06-10-2011, 04:48 PM
  3. Help ! Read from txt to array an than search
    By kram54 in forum New To Java
    Replies: 1
    Last Post: 12-09-2010, 12:52 AM
  4. Search in the array
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 4
    Last Post: 04-28-2010, 09:02 AM
  5. Search through objects
    By MarcusD in forum New To Java
    Replies: 8
    Last Post: 04-14-2009, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •