Bug 118156 - Syntax valildation for While Loop Construct is in error
Summary: Syntax valildation for While Loop Construct is in error
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-27 12:35 EST by Ed Churchill CLA
Modified: 2005-11-27 16:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Churchill CLA 2005-11-27 12:35:21 EST
The following block of code causes the syntax error
Syntax error, insert ";" to complete Statement
at the tilde:
While(iterator.hasNext())~{
	Integer boxedInteger = (Integer)iterator.next();
	bills.append(boxedInteger);	
}
If I insert the ";", other areas of the code are show to have errors.
---------------------
The full code I'm using to get my self familiar with the 
Eclipse JDE is:

package Intro.core;
//import java.util.ArrayList;
import java.util.*;

/**
 * @author Ed Churchill
 * EdChurchill@austin.rr.com
 */
public class Adult {
	protected int age = 25;
	protected String name = "Bob";
	protected String race = "inuit";
	protected String gender = "male";
	protected String firstname = "firstname";
	protected String lastname = "lastname";
	public int progress = 0;
	protected ArrayList wallet = new ArrayList();
	
	public static void main(String[] args){
		Adult myAdult=new Adult();
		
		myAdult.addMoney(new int[] {1,5,10,20,50,100});
		
		StringBuffer bills = new StringBuffer();
		Iterator iterator = myAdult.getWallet().iterator();
		do {
			Integer boxedInteger = (Integer)iterator.next();
			bills.append(boxedInteger);	
		}while(iterator.hasNext());
/*
		While(iterator.hasNext()){
			Integer boxedInteger = (Integer)iterator.next();
			bills.append(boxedInteger);	
		}
*/
		System.out.println(bills.toString());
		
	}
	public Adult() {
	}
	
	public Adult(String aFirstname, String aLastname){
		firstname = aFirstname;
		lastname = aLastname;
	}
	
	public int getAge(){
		return age;
	}
	public void setAge(int anAge){
		age = anAge;
	}
	public String speak(){
		StringBuffer speech = new StringBuffer();
		for(int i=0; i<3; i++){
			speech.append("hello ");
		}
		return speech.toString();
	}
	public String getName(){
		return firstname.concat(" ").concat(lastname);
	}
	public String walk(int steps){
		if(steps > 100)
			return "I can't walk tht far at once";
		else if (steps > 50)
			return "That's almost too far";
		else{
			progress += steps;
			return "Just took " + steps + " Steps";
		}
	}
	public ArrayList getWallet(){
		return wallet;
	}
	public void setWallet(ArrayList aWallet){
		wallet = aWallet;
	}
	public void addToWallet(int bill){
		Integer boxedBill=new Integer(bill);
		wallet.add(boxedBill);
	}
	public void addMoney(int bill){
		addToWallet(bill);
	}
	public void addMoney(int[] bills){
		for (int i=0;i<bills.length;i++){
			int bill = bills[i];
			addToWallet(bill);
		}
	}
	
	
	public void spendMoney(int bill){
		Integer boxedBill = new Integer(bill);
		boolean haveThatBill = wallet.contains(boxedBill);
		
		if(haveThatBill){
			wallet.remove(boxedBill);
		}else{
			System.out.println("I don't have that bill");
		}
	}
}
Comment 1 Olivier Thomann CLA 2005-11-27 16:59:42 EST
When you type,

While(iterator.hasNext())~{
        Integer boxedInteger = (Integer)iterator.next();
        bills.append(boxedInteger);     
}

';' is a possible solution to fix the syntax error. This doesn't mean this is the only solution or the right solution. In this case, simply delete the tilde.
Closing as WORKSFORME.
Reopen if this doesn't solve your problem.