Results 1 to 4 of 4

Thread: Builder problem in java

  1. #1
    Join Date
    Apr 2008
    Posts
    240

    Builder problem in java

    Hi
    I am trying a program to build a method that combines the use of a string tokenizers and string builder. This will translate words in a string to other words. But the problem is that it is the method is giving an error. Can someone tell me how to solve this problem. please help. Thanks in advance.
    Code:
    public void String reppirate(String +pirate+, String +english+) {    (class, interface or enum expected)
        StringBuilder rst = new StringBuilder(original.length());
        String delmt = "+-*/(),. ";
        StringTokenizer st = new StringTokenizer(+pirate+, delmt, true);
        while (st.hasMoreTokens()) {
            String w = st.nextToken();
            if (w.equals(find)) {
                rst.append(+english+);
            } else {
                rst.append(w);
            }
        }
        return rst.toString();
    }

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Builder problem in java

    Hi
    Think there is a problem in your program statement.
    Code:
    public void String reppirate(String +pirate+, String +english+) {
    I think you are trying to say this
    Code:
    public String reppirate(String pirate, String english) {
    Just verify is this correct.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Builder problem in java

    Hi
    I read your code, I have some doubts in mind.
    Code:
    public void String reppirate(String +pirate+, String +english+) {    (class, interface or enum expected)
        StringBuilder rst = new StringBuilder(original.length());
        String delmt = "+-*/(),. ";
        StringTokenizer st = new StringTokenizer(+pirate+, delmt, true);
        while (st.hasMoreTokens()) {
            String w = st.nextToken();
            if (w.equals(find)) {
                rst.append(+english+);
            } else {
                rst.append(w);
            }
        }
        return rst.toString();
    }
    1) The first doubt is that why do you have the "+" sign in your parameter names? Think that could be causing the problem.
    2) Second problem is the variables are not declared, "original" and "find".

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Builder problem in java

    Hi
    I read you code and have posted a program below. Please check this may the code you are searching for.
    Code:
    public class Test
    {
    	public String reppirate(String pirate, String english)
    	{
    		StringBuilder rst = new StringBuilder(original.length());
    		String delimiters = "+-*/(),. ";
    		StringTokenizer st = new StringTokenizer(pirate, delimiters, true);
    		while (st.hasMoreTokens()) {
    			String w = st.nextToken();
    			if (w.equals(find)) {
    				rst.append(english);
    			} else {
    				rst.append(w);
    			}
    		}
    		return rst.toString();
    	}
    }
    If any problems or queries in future, the do post.

Similar Threads

  1. Flash Builder 4 Extremely slow under Windows 7 + Java
    By MadhaviS in forum Software Development
    Replies: 7
    Last Post: 08-10-2010, 11:58 AM
  2. Flex Builder Shareable App Problem
    By Conqueror in forum Windows Software
    Replies: 6
    Last Post: 13-07-2010, 12:21 AM
  3. SQL Query Builder
    By LasitMalinga in forum Software Development
    Replies: 5
    Last Post: 29-04-2009, 03:15 PM
  4. Problem with PE Builder plugin
    By Aapti in forum Operating Systems
    Replies: 3
    Last Post: 31-03-2009, 06:35 PM
  5. C++ Builder
    By Deskmukh in forum Software Development
    Replies: 2
    Last Post: 28-02-2009, 01:00 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,751,424,105.74496 seconds with 16 queries