advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Articles : JavaBoutique's Introduction to Java :
Data Types and Operators :

Contents
Comments
Printing to Standard Output
Variables
- Data Types
- Declaring, Assigning, and Casting
- Variable Type Helper Objects
Strings
Arrays
Operators
Flow Control

Variable Type Helper Objects

So far, the variable types we have discussed are called "primitive types" because they represent simple values that have built-in characteristics. They are fixed elements. Java also provides a set of "reference types" that include object arrays, strings, and other more complex data structures.

We'll talk more about reference types later when we are using them. However, it is good to note that Java provides reference "wrapper" types for each primitive type that include manipulative functionality.

These classes can all be found in java.lang and include: Boolean, Character, Double, Float, Integer, Long, and String.

Each class contains helper methods that allow you to more easily work with the values. One of the most useful features provided by the wrapper classes is the ability to easily change from one type to another. Thus, you can change an integer value to its string representation using something like:

     Integer(20).toString();

Consider the list of methods in the following objects:

Boolean
final static Boolean FALSE Creates a Boolean with a false value
final static Boolean MAX_VALUE Returns 65535 (this was placed in the boolean class by mistake)
final static Boolean MIN_VALUE returns 0 (this was placed in the boolean class by mistake)
final static Boolean TRUE Creates a Boolean with a true value
Boolean(String s) Creates a Boolean based on the string. true is true. Everything else is false.
Boolean (boolean value) Creates a Boolean with specified boolean value
boolean booleanValue() returns the boolean value of the Boolean object
boolean equals(Object object) Returns true if the objects are equal, false if not.
static boolean getBoolean(String s) Returns true if s is true. Otherwise it returns false.
int hashCode() Returns the Boolean's hash code.
String toString() Returns the string representation of the Boolean.
static Boolean valueOf(String s) Returns a Boolean representation of the string
Character
final static int MAX_RASIX The maximum radix that can be used in converting a number to an int (represented as a character). The value is 36.
final static int MIN RADIX Same as above but returns 2
Character (char value) Returns a Character representation of value.
char charValue() Returns the char representation of the Character object
static int digit(char ch, int base) Converts ch to int.
boolean equals(Object o) Tests for equality between the objects.
static char forDigit(int digit, int base) Returns the char representation of the digit in the specified base.
int hashCode() Returns the hash code.
static boolean isDigit(char c) Returns true if the char value is between 0 and 9
static boolean isJavaLetter(char c) Returns true if the ch is a alphabet character, $, or _
static boolean isLetter(char c) Returns true of the char is a letter
static boolean isLetterOrDigit(char c) Returns true of the char is a letter or a digit
static boolean isLowerCase(char c) Returns true of character is lower case.
static boolean isSpace(char c) Returns true of the character is a space, tab, newline, or return
static boolean isUpperCase(char c) Returns true of character is upper case.
static char toLowerCase(char c) Converts a char to lower case.
String toString() Returns the String representation of the Character
static char toUpperCase(char c) Returns the Uppercase value of the Character
Double
final static double MAX_VALUE returns the max value
final static MIN_VALUE Returns the min value
final static double NaN A double that is not a number
final static double NEGATIVE_INFINITY -1.0/0.0
final static double POSITIVE_INFINITY 1.0/0.0
Double(double value) Returns a Double representation of the double value.
Double (String s) throws NumberFormatExcepion Returns a Double representation of the string value.
static long double doubleToLongBits(double value) Returns the bit representation
double doubleValue() Returns the double representation of the Double.
boolean equals(Object o) Tests for equality
float floatValue() Returns the float representation of the Double
int hashCode() Returns the hash code
int intValue() Returns the int representation of the Double.
boolean isInfinite() Returns true if equal POSITIVE or NEGATIVE infinity
static boolean isInfinite(double d) Returns true of true.
boolean isNaN() Returns true if Double is NaN
static double longBitsToDouble(long l) Double representation of the bits
long longValue() Returns the long representation of the Double.
String toString() Returns the String representation of the Double
static String toString(double d) Converts d to String
static Double valueOf(String s) throws NumberFormatException Converts String to Double
Float
final static float MAX_VALUE returns the max value
final static float MIN_VALUE Returns the min value
final static float NaN A double that is not a number
final static float NEGATIVE_INFINITY -1.0/0.0
final static float POSITIVE_INFINITY 1.0/0.0
Float(double value) Returns a Float representation of the double value.
Float(float value) Returns a Float representation of the float value.
Float (String s) throws NumberFormatExcepion Returns a Float representation of the string value.
double doubleValue() Returns the double representation of the Float.
boolean equals(Object o) Tests for equality
static int floatToIntBits(float value) Returns the bit representation
float floatValue() Returns the float representation of the Float
int hashCode() Returns the hash code
static float intBitsToFloat(int value) Returns the float representation of the int bits
int intValue() Returns the int representation of the Float.
boolean isInfinite() Returns true if equal POSITIVE or NEGATIVE infinity
static boolean isInfinite(float f) Returns true of true.
boolean isNaN() Returns true if Double is NaN
long longValue() Returns the long representation of the Float.
String toString() Returns the String representation of the Float
static String toString(float f) Converts f to String
static Float valueOf(String s) throws NumberFormatException Converts String to Float
Integer
final static int MAX_VALUE returns the max value
final static int MIN_VALUE Returns the min value
Integer(int value) Returns an Integer representation of the int value.
Integer (String s) throws NumberFormatExcepion Returns an Integer representation of the String value.
double doubleValue() Returns the double representation of the Integer.
boolean equals(Object o) Tests for equality
float floatValue() Returns the float representation of the Integer
static Integer getInteger(String propName) Returns System property with given key
static Integer getInteger(String propName, int val) Returns System property with given key
int hashCode() Returns the hash code
int intValue() Returns the int representation of the Integer.
long longValue() Returns the long representation of the Integer.
static int parseInt(String s) throws NumberFormatException Returns the int representation of the String
String toString() Returns the String representation of the Integer
static String toString(int i) Converts i to String
static Integer valueOf(String s) throws NumberFormatException Converts String to Integer
Long
final static long MAX_VALUE returns the max value
final static long MIN_VALUE Returns the min value
Long(long value) Returns a Long representation of the long value.
Long (String s) throws NumberFormatExcepion Returns a Long representation of the String value.
double doubleValue() Returns the double representation of the Long.
boolean equals(Object o) Tests for equality
float floatValue() Returns the float representation of the Long
static Long getLong(String propName) Returns System property with given key
static Long getLong(String propName, long val) Returns System property with given key
int hashCode() Returns the hash code
int intValue() Returns the int representation of the Long.
long longValue() Returns the long representation of the Long.
static long parseLong(String s) throws NumberFormatException Returns the long representation of the String
String toString() Returns the String representation of the Long
static String toString(long l) Converts l to String
static Long valueOf(String s) throws NumberFormatException Converts String to Long

NEXT


Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena curently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 IBM Software Construction Toolbox
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 33
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Citrix CTO Eyes the Future of Virtualization
The Pitfalls of Open Source Litigation
LiMo Open to Working With Google on Mobile
Google Gadgets Under Attack at Black Hat
IBM, Linux and the Microsoft-Free PC
Opengear's Open Source Odyssey
Sun Moves JavaFX Closer to Primetime
Will LSB 4 Standardize Linux?
Making a Case for an Android-Symbian Merger
Ubuntu Launchpad Opens Up Development

Base Concepts of Internationalization in PHP
An Introduction to F# for Functional Programming
The Basics of REALbasic, Cross-platform RAD Tool in the Mold of VB
Silverlight Streaming: Free Video Hosting for All
What's New in ASP.NET 3.5?
Putting SharePoint to Work for You
Putting Intel® Threading Building Blocks to Work
Achieve the Best of Two Worlds with Behavior-Driven Development
Understanding Windows Mobile Security
RODCs Transform Branch Office Security

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers