return data type

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 2
Reputation: Nazzy is an unknown quantity at this point 
Solved Threads: 0
Nazzy Nazzy is offline Offline
Newbie Poster

return data type

 
0
  #1
Mar 7th, 2006
Hello,

I am having a lot of difficulty with this program. I have to find the data types of strings that have been inputted by users into the command line. I have used StringTokenizer to break data into strings but I am not sure where to go from there. How do I take these tokens and find out what data types they are.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: return data type

 
0
  #2
Mar 8th, 2006
Do you have any test data that we could see? What is an expected input and then the corresponding output?
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 2
Reputation: Nazzy is an unknown quantity at this point 
Solved Threads: 0
Nazzy Nazzy is offline Offline
Newbie Poster

Re: return data type

 
0
  #3
Mar 8th, 2006
This is what i have so far:

// File: Classify.java

// Purpose: classifies input into primitive types or String

import java.io.*;
import java.util.StringTokenizer;

public class Classify {

public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
String str = in.readLine();
while (str != null) {
StringTokenizer tokenizer = new StringTokenizer(str);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();




}

str = in.readLine();
}
} // main

} // class Classify

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: return data type

 
0
  #4
Mar 8th, 2006
Originally Posted by Nazzy
This is what i have so far:

// File: Classify.java

// Purpose: classifies input into primitive types or String

import java.io.*;
import java.util.StringTokenizer;

public class Classify {

public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
String str = in.readLine();
while (str != null) {
StringTokenizer tokenizer = new StringTokenizer(str);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();




}

str = in.readLine();
}
} // main

} // class Classify

Thanks.
Erm, that's not test data, that's your program. Tee he he.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: return data type

 
0
  #5
Mar 8th, 2006
Well, you could write boolean methods like this:

  1.  
  2. boolean testInt(String s)
  3. {
  4. try
  5. {
  6. Integer.parseInt(s);
  7. }
  8. catch(Exception e)
  9. {
  10. return false;
  11. }
  12. return true;
  13. }

or something like that.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC