Hi, I was hoping if anyone could help me really quickly. A section of my program needs to discern between java primitives. I've had to make regular expressions which look for the different characteristics between each primitive, but I don't know what some of them are. Below are all the primitives that I need to tell apart. The bolded ones are the ones I know. I was hoping if anyone could tell me what a byte or short is. Or what the differences between a long, float and double are. Sorry for the HELP! in the title, but this program is due at 12:00am sharp, and it's 10:21pm where I am =(


11 Years
Discussion Span
Last Post by freesoft_2000

In a nut shell...

byte is a single byte, signed, no decimal places
double and float have decimal places, signed, double is just a bigger form of float
long, short, int are signed, NO decimal places. Long is the biggest, then int, then short, byte is pretty much in this group too
char holds a char
boolean holds a true/false


Hi everyone,

I am not sure if your program is due yet but here i go

A section of my program needs to discern between java primitives

After many years of programming, i can say if you have such a need in your program, your program is designed badly. You need to redesign it.

Think of it this way, you can only cast it if you know its primitive or else you can never know its value.

You can do what alot of C++ programmers do and that is create you own primitive parsing classes using array strings

For example

Like this

String[2] str1 = new String[2];
int po = 5;

str1[0] = "Integer";
str1[1] = Integer.toString(po);

Using the above technique you can read any primitive from a serialized string array form or anywhere else but beware doing this can make your program very complicated and i would stay away from this if i were you

Richard West

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.