| Author |
Language Fundamentals
|
shaan nimaz
Greenhorn
Joined: May 27, 2006
Posts: 5
|
|
hi , i just want to get the minimum & maximum values of each signed datas.so i simply wrote a code as given below. class A { public static void main (String args[]) { System.out.print(Byte.MIN_VALUE+","); System.out.print(Byte.MAX_VALUE); }} but it works for byte,long & int only. not for short. if i wanna get the MIN_VALUE & MAX_VALUE for short , what do i do?
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Originally posted by shaan nimaz: ...but it works for byte,long & int only. not for short. if i wanna get the MIN_VALUE & MAX_VALUE for short , what do i do?
What exactly did you try for Short? (Did you perhaps use a lowercase 's' accidently?) It should work fine...
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
|
Works fine if you replace Byte by Short, it prints -32768,32767
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
shaan nimaz
Greenhorn
Joined: May 27, 2006
Posts: 5
|
|
hii marc, thank you for the reply. but i tried to compile your code then then it gave some errors . Shorter.java:5: cannot find symbol symbol : variable MIN_VALUE location: class Short System.out.println(Short.MIN_VALUE); ^ Shorter.java:6: cannot find symbol symbol : variable MAX_VALUE location: class Short System.out.println(Short.MAX_VALUE); ^ 2 errors
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Short is in the java.lang package, so you need to import it. import java.lang.Short; or import java.lang.*;
|
[My Blog]
All roads lead to JavaRanch
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
The java.lang package is imported by default, so there is no need for any import statements. I don't understand why you're getting errors with this. As far as I can tell, these fields have been in the Short class since Java 1.1. What version of Java are you using? And did you download this from Sun?
|
 |
shaan nimaz
Greenhorn
Joined: May 27, 2006
Posts: 5
|
|
Originally posted by marc weber: The java.lang package is imported by default, so there is no need for any import statements. I don't understand why you're getting errors with this. As far as I can tell, these fields have been in the Short class since Java 1.1. What version of Java are you using? And did you download this from Sun?
i am using JDK1.5 . I DONT KNOW WHY I AM GETTING ERRORS?
|
 |
 |
|
|
subject: Language Fundamentals
|
|
|