Results 1 to 2 of 2
  1. #1
    zaper is offline Member
    Join Date
    Apr 2013
    Posts
    7
    Rep Power
    0

    Unhappy [Java]Simple Mistake

    I'm having codes

    package Zjazd3;

    Java Code:
    public class main {
    
    	  public static void main(String[] args) {
    		    Appender ap = new Appender("Ala");
    		    ap.append(" ma kota", 3).append( " i psa", 2);
    		    System.out.println(ap);
    		    ap.append(" ojej", 3);
    		    System.out.println(ap);
    		  }
    
    }
    Java Code:
    package Zjazd3;
    import java.lang.IllegalArgumentException;
    
    public class Appender {
    
    	String napis;
    	
    	public Appender(){		
    		napis = "";	
    	}
    	
    	public Appender(String s){
    		napis = s;
    	}
    	
    	 Appender append(String app, int n){
    		
    		String s1 = app;
    		
    		for(int i=0; i<n; i++){
    			  try{
                      napis = napis + s1;
                     }
    			  catch (Exception e) {
                    throw new IllegalArgumentException();
    			  	 }
              } 	
    		return new Appender (napis);
    	}
    }
    When I run the program I see an error

    Zjazd3.Appender@64c3c749
    Zjazd3.Appender@64c3c749

    Help Please

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: [Java]Simple Mistake

    That is no error. Appender doesn't override toString(). What you see id the current String representation of the Appender objects.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Factorial - java.lang.stackoverflow? Where's the mistake?
    By SwordMaster in forum New To Java
    Replies: 3
    Last Post: 12-03-2012, 06:05 PM
  2. Hello, I got a mistake
    By F1ke in forum New To Java
    Replies: 7
    Last Post: 09-25-2011, 08:11 PM
  3. Point my mistake
    By amzers in forum New To Java
    Replies: 11
    Last Post: 12-16-2010, 12:31 PM
  4. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 3
    Last Post: 04-29-2009, 05:26 AM
  5. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 2
    Last Post: 04-28-2009, 06:30 AM

Tags for this Thread

Posting Permissions

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