• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Language Fundamentals

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works fine if you replace Byte by Short, it prints -32768,32767
 
shaan nimaz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic