Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by snotmare View Post
    ...however, I am also correct. This is what I was referring to...

    Java Code:
    String test1 = "test";
    String test2 = "test";
    
    System.out.println(test1 == test2);
    The output for this is true.
    snotmare, there are many other situations where String equality doesn't work, and in situations where you just can't predict. Please don't recommend this to newbies in your posted code.

  2. #22
    Claymz is offline Member
    Join Date
    Apr 2011
    Posts
    25
    Rep Power
    0

    Default

    Another problem, last one i think:

    I get this error messages, when i use this method, which should get all possible combinations of N elements at a time, for example, if i have a Train which has 8 elements, and user types into command promt number 3, then the method needs to delete one wagon or add one wagon - it needs to make all possible combinations, which are made out of operations over those 3 elements in our case(adding or deleting: for example, one added and two deleted or three deleted etc.). Those 3 elements can be any of the whole 8 elements of the Train.

    Exception in thread "main" java.lang.StackOverflowError
    at Train.configuration(Naloga05.java:499)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    at Train.configuration(Naloga05.java:504)
    ...

    what to do? also, the code:

    Java Code:
    	public void configuration(int n){
    		curEl = first;
    		//adds a wagon
    		while(curEl.next != null) {
    			Train temp = new Train();
    			//make a new temporary Train
    			TrainElement ElCounter = first;
    			while(ElCounter.next != null)
    			{
    				temp.add(ElCounter.next.element); //first errror
    			 	ElCounter = ElCounter.next;
    			}
    			
    			temp.add(curEl.next.element);
    			temp.configuration(n-1); //second error
    			curEl = curEl.next;
    		}
    		
    		int numElements = 0;
    		curEl = first;
    		while(curEl.next != null)
    		{
    			numElements++;
    			curEl = curEl.next;
    		}
    		
                    //gets rid of one wagon
    		int counter = 1;
    		while(counter< numElements) { 
    			Train temp = new Train();
    			//make a new temporary Train
    			TrainElement ElCounter = first;
    			while(ElCounter.next != null)
    			{
    				temp.add(ElCounter.next.element);
    			 	ElCounter = ElCounter.next;
    			}
    			
    			temp.drop(counter);
    			temp.configuration(n-1);
    		}
    	}
    Maybe i need to modify size of a stack in eclipse? how?
    Last edited by Claymz; 04-18-2011 at 12:25 PM.

  3. #23
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Claymz View Post
    Maybe i need to modify size of a stack in eclipse? how?
    No! You need to fix the error. Which lines are causing the error?

  4. #24
    Claymz is offline Member
    Join Date
    Apr 2011
    Posts
    25
    Rep Power
    0

    Default

    ive marked the two in the code above with "first" and "second error"

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Sharing Data Members between two JFrames
    By PrinceSendai in forum AWT / Swing
    Replies: 3
    Last Post: 10-17-2010, 03:51 AM
  2. private data members?
    By blueduiker in forum New To Java
    Replies: 10
    Last Post: 01-19-2010, 12:13 PM
  3. [newbie] getting class members from Arraylist
    By jon80 in forum New To Java
    Replies: 16
    Last Post: 05-15-2009, 08:45 AM
  4. Replies: 6
    Last Post: 02-11-2009, 11:51 AM
  5. Doclet that prints out all members of the class
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 12:06 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
  •