word « StringTokenizer « Java Data Type Q&A





1. StringTokenizer to remove 3 consecutive words    coderanch.com

Hi guys, look at my code below. my goal is to eliminate the words "on the moon" from the sentence: "there is a man on the moon with a dell computer"; I receive this result: r is a a wi a DELL cpur import java.util.*; public class Editor { public static void main(String args[]) { String str = "there is a ...

2. Read a line of text and reverse each word do not use StringTokenizer    coderanch.com

I have tried a lot but i am not able to remove the ArrayIndexOutOfBounds Exception at runtime but it compiles just fine import java.util.*; public class Rev { static void rev(String jik){ //method to reverse the given string int i,j; char ji[]=new char[jik.length()]; for(i=0,j=jik.length();i=0;j--){ ji[i]=jik.charAt(j); i++; } String jk=ji.toString(); System.out.println(jk+" "); } public static void main(String[] arg){ int i,start,fin; start=0; String ...

3. Java stringtokenizer- making it reverse word    java-forums.org

Within your while loop, you are calling the nextToken() method twice, meaning that it is reading two tokens for each pass through the loop rather than just one. You should store the return value of the first call to nextToken() in a String variable, and refer to that variable later in the loop rather than calling nextToken() a second time. Also, ...