Results 1 to 3 of 3

Thread: ArrayList and type the return

  1. #1
    Join Date
    Nov 2008
    Posts
    25

    ArrayList and type the return

    Hello
    i have a probleme with my class essentielly with my method look my class
    import java.util.ArrayList;
    import java.util.Iterator;

    Code:
    public class Personne {
    	ArrayList persones=new ArrayList<Personne>();
    	private long id;
    	private String nom="";
    	public  long getId(){
    		return id;
    	}
    	public String getNom(){
    		return nom;
    	}
    	public long setId(long id){
    		return id=id;
    	}
    	public String setNom(String nom){
    		return nom=nom;
    	}
    //here the problem the return 
    	public String getPersone(){
    		Iterator iterateur=persones.iterator();
    		while(iterateur.hasNext()){
    			long id=((Personne)iterateur.next()).getId();
    			String nom=((Personne)iterateur.next()).getNom();
    			return id+""+nom;
    		}
    		return null;
    	}
    public static void main(String arg[]){
    	
    	Personne p1=new Personne();
    	p1.setNom("Amine");
    	p1.setId(0xAA3567B2C4FL);
    	Personne p2=new Personne();
    	p2.setId(0xAA93B10CD00L);
    	p2.setNom("Ali");
    	}
    }
    thanks

  2. #2
    Join Date
    Jun 2006
    Posts
    623

    Re: ArrayList and type the return

    Service operations can only operate on concrete implementations. This is not a limitation of WCF, this is a limitation (or, feature) of WSDL. So, if you want to accept any type to a generic Load() operation, and specify the type in the call, you'll have to design a contract that receives the type T as a parameter, and returns a List<object> or object[] that is an array of that type. I think you are fixated on the syntax looking like remoting, and generics...when what you really want is a solution that fits with semantics of service design.

    Why not this?

    List<object> Load(string objectType);

  3. #3
    Join Date
    Nov 2008
    Posts
    25

    Re: ArrayList and type the return

    thanks ,
    my probleme concerne my methode getPersonne returns the id and name

Similar Threads

  1. Replies: 1
    Last Post: 16-08-2010, 05:25 PM
  2. Replies: 1
    Last Post: 16-08-2010, 04:44 PM
  3. Implement the return type in java
    By Captain Carrot in forum Software Development
    Replies: 4
    Last Post: 25-03-2010, 01:34 PM
  4. Incorrect return of ArrayList
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 04:34 AM
  5. Static types can we used as return type
    By ComPaCt in forum Software Development
    Replies: 2
    Last Post: 12-06-2009, 03:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,846,506.90644 seconds with 16 queries