Results 1 to 2 of 2
Thread: Using the scanner class
- 03-12-2009, 08:07 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 3
- Rep Power
- 0
Using the scanner class
Im trying to scan a string from the user (System.in) and then use a delimiter to remove blank spaces and make the input one string eg.
if the user enters:
com puter,
the output should be "computer"
but Im having probs with the code;heres what i have so far:
System.out.println(" Enter The Name for the Lab : ");
if (labscan.hasNext());
{
lab1 = labscan.nextLine();
labscan1 = new Scanner(lab1);
//labscan1.useDelimiter(" ");
while (labscan1.hasNext());
labscan1.useDelimiter(" ");
str = "";
lab1 = labscan1.next() + str;
labobj1.setName(lab1);
System.out.println();
}
can u help me out please?
- 03-13-2009, 10:49 AM #2
Similar Threads
-
Use of Scanner class and Delimiter
By tjhodge in forum New To JavaReplies: 3Last Post: 02-12-2009, 05:26 PM -
Scanner Class...
By TheRocket in forum New To JavaReplies: 5Last Post: 12-05-2008, 09:48 AM -
Scanner class question
By Rgfirefly24 in forum New To JavaReplies: 5Last Post: 04-25-2008, 12:41 AM -
Scanner class
By ajaymenon.k in forum Advanced JavaReplies: 1Last Post: 11-26-2007, 07:01 AM -
JDK 5.0 Scanner Class
By Sircedric88 in forum New To JavaReplies: 3Last Post: 07-27-2007, 06:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks