Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check whether the entered value is what type

 
chenna reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

How to check the entered value is of which primitive type?

regards,
Naresh
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chenna reddy wrote:

How to check the entered value is of which primitive type?



entered value ...? from where???
i didn't understand your problem. what i know if you are entering any data through keyboard or any textfield it will always be a string.
please make your question a bit more clear.
avi sinha
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
chenna reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is how to know whether the entered value is a string or int or float or char. Is there any specific method are there to know?
 
Ranveer K Kumar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chenna reddy wrote:The question is how to know whether the entered value is a string or int or float or char. Is there any specific method are there to know?


Please lets know as avi sinha's asked from where you want to enter, for example in web the input values will string always..
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Determining whether a String like "Campbell" "123" or "123.45" can represent a number or an integer looks like a job for regular expressions. Whether the String "1" represents writing with a number in, an integer 1, a floating-point 1.0 or the character '1' is for you to decide.
You will find more about the Java™ grammar for such "primitives" in this Java Language Specification section.
 
chenna reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Determining whether a String like "Campbell" "123" or "123.45" can represent a number or an integer looks like a job for regular expressions. Whether the String "1" represents writing with a number in, an integer 1, a floating-point 1.0 or the character '1' is for you to decide.
You will find more about the Java™ grammar for such "primitives" in this Java Language Specification section.


Thank you.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic