File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Language Fundamentals

 
shaan nimaz
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works fine if you replace Byte by Short, it prints -32768,32767
 
shaan nimaz
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short is in the java.lang package, so you need to import it.

import java.lang.Short;
or
import java.lang.*;
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic