functions?

what if I wanna test if an integer is really an integer what will i do?

if in PHP ther is a ceratain **** as is_string or is_boolean or is_int

well how bout in JAVA then?

[190 byte] By [nemo666a] at [2007-11-27 11:37:29]
# 1

> well how bout in JAVA then?

Integer.parseInt() is one way. Regular expressions are another. Character.isDigit() is another. That's just a start.

~

yawmarka at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 2

Write an application that reads five integers, determines and prints the largest and smallest integers in the group. Use only the programming techniques you learned in this chapter.

nemo666a at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 3

> Write an application that reads five integers,

> determines and prints the largest and smallest

> integers in the group. Use only the programming

> techniques you learned in this chapter.

You probably didn't mean for that to sound like you want someone to do your homework. So, what's your specific, code-related question?

~

yawmarka at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 4

since I know a lil in PHP

my specific question is how am I going to test

the input integer if it was realy an integer ? or else if its not ..output

in PHP the code can be like this

if (is_int(num1))

{

echo "the 1st input is an integer";

}

else

{

echo "it is not an integer";

}

how bout in java how will you apply such logic in comparing? such like that

i just shown

nemo666a at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 5

> my specific question is how am I going to test the input integer if it was realy an integer ?

See reply #1. Which part of reply #1 did you find confusing?

~

yawmarka at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 6

sorry friend, its back to the ranch with you

http://java.sun.com/docs/books/tutorial/java/index.html

TuringPesta at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 7

Integer.parseInt() Character.isDigit()

these two things.. I have encounter those two in using JOption pane

but I'm using the java.util.Scanner instead Integer.parseInt(JOptionPane.showInputDialog("enter number: "));

ouch..my nose is bleeding ! :(

nemo666a at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 8

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html

TuringPesta at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 9

> Integer.parseInt() Character.isDigit()

>

>

> these two things.. I have encounter those two in

> using JOption pane

So? They have nothing to do with JOptionPane See the Integer in front of the parseInt and the Character in front of the isDigit. That means they are static methods of the corresponding classes. They are totally independent of JOptionPane and you can use them anywhere you like in your code.

Try a bit of lateral thinking.

floundera at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...
# 10

Did you look at the documentation of the Scanner class?

int number;

If( Scanner.hasNextInt() ) number=Sxanner.nextInt();

else System.out.println("not an Integer");

Just have to insert "try" and "catch" because Scanner.nextInt throws an Exception.

SpiderPiga at 2007-7-29 17:14:47 > top of Java-index,Java Essentials,New To Java...