Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String prog  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me in a program i.e
if i enter a string 123 then the output should be displayed as the entered string is Numeric.
and if i enter the string 123abc the output should be displayed as entered string is Alphanumeric.

please help me out regarding this i am a beginner so its little confusing !!
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

java.util.Scanner lets you do both getting the input from users and checking if it's a number.
 
Ranch Hand
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use regex to find out.

Here is my example.
http://www.coderanch.com/t/561513/java/java/new-matchres

Replace

with
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!