Results 1 to 2 of 2
  1. #1
    Saletra is offline Member
    Join Date
    Jul 2010
    Posts
    11
    Rep Power
    0

    Default Selecting min size and returning reference to object

    Hello,

    Java Code:
    	
    	Kasy[] tab= new Kasy[4];
    	tab[0]= kasa1;
    	tab[1]= kasa2;
    	tab[2]= kasa3;
    	tab[3]= kasa4;
    	  int minValue = kasa1.klienci.size();
    	  for(int i=0;i<3;i++){
    	    if(tab[i].klienci.size() < minValue){
    		  minValue = tab[i].klienci.size();
    		}
    	    }
    	  return minValue;
    This gives me the smallest number, but what I really need is reference to object which have the smallest size() (kasa1, kasa2, kasa3 or kasa4).

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Have another variable of type Kasy and save a reference to the smallest element in the tab array as you find it in the loop.

Similar Threads

  1. Method, returning reference to an object
    By Saletra in forum New To Java
    Replies: 3
    Last Post: 08-23-2010, 08:22 PM
  2. Object and reference
    By katie in forum New To Java
    Replies: 2
    Last Post: 10-19-2009, 03:45 PM
  3. Very new to Java, how to reference an object
    By tornado in forum New To Java
    Replies: 3
    Last Post: 12-05-2008, 12:51 AM
  4. Object reference to number
    By dayneo in forum New To Java
    Replies: 4
    Last Post: 05-27-2008, 01:23 PM
  5. Getting the Object Reference Name
    By Deathmonger in forum New To Java
    Replies: 2
    Last Post: 03-12-2008, 02:51 PM

Posting Permissions

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