How Many Java Primitive Types?

I always thought there were 8. And so the docs say, lol.

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

But it seems our friends at JavaWorld might disagree:

http://www.javaworld.com/javaworld/jw-09-1996/jw-09-bytecodes.html?page=2

Are they just counting boolean as a byte? Or is it just an embarrassing typo?!

(If this is an interview trick question i'd like to know)

[432 byte] By [TuringPesta] at [2007-11-27 5:24:37]
# 1
Well it's not a typo because they do not mention the boolean primitive at all. I guess JavaWorld's article is at fault unless they have a good reason for not considering boolean as a primitive. Although if that's the case, they fail to explain it in their article...
Dalzhima at 2007-7-12 14:43:59 > top of Java-index,Java Essentials,Java Programming...
# 2
How did ronda's post disappear?> You have confused the Java language with the Java> Virtual Machine.Yea. That would be it.D amn, i thought i finally had those know-it-alls at java world, lol. ;)
TuringPesta at 2007-7-12 14:43:59 > top of Java-index,Java Essentials,Java Programming...
# 3
Language, or VM?Language includes boolean, VM does not. http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#22239
mlka at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 4

"...expressions in the Java programming language that operate on boolean values are compiled to use values of the Java virtual machine int data type."

Odd... wouldn't it save a few bytes of memory (3 to be exact) to use a byte? Not that one generally creates a large abundance of boolean's (in the source code, that is)

Message was edited by:

bsampieri

bsampieria at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 5

> "...expressions in the Java programming language that

> operate on boolean values are compiled to use values

> of the Java virtual machine int data type."

>

> Odd... wouldn't it save a few bytes of memory (3 to

> be exact) to use a byte? Not that one generally

> creates a large abundance of boolean's (in the source

> code, that is)

>

> Message was edited by:

> bsampieri

According to ronda's (now defunct for some reason) post, some JVMs use an int, some use a byte

georgemca at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 6

> "...expressions in the Java programming language that

> operate on boolean values are compiled to use values

> of the Java virtual machine int data type."

>

> Odd... wouldn't it save a few bytes of memory (3 to

> be exact) to use a byte? Not that one generally

> creates a large abundance of boolean's (in the source

> code, that is)

You should have kept reading:

The Java virtual machine does directly support boolean arrays. Its newarray instruction enables creation of boolean arrays. Arrays of type boolean are accessed and modified using the byte array instructions baload and bastore.2

kajbja at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 7

> According to ronda's (now defunct for some reason)

> post, some JVMs use an int, some use a byte

It looks like they blew up her account:

http://onesearch.sun.com/search/onesearch/index.jsp?col=developer-forums&subCat=siteforumid%3Ajava31&rt=false&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&advanced=true&required=&exact=&oneof=&exclude=+&cs=false&nh=10&since=&rf=0&doctypeAll=all&doctype=pdf&doctype=html&doctype=xml&doctype=plain&reslang=en&author=ronda

I searched for any posts authored by ronda in the advanced search, but there weren't any found.

hunter9000a at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 8
> I searched for any posts authored by ronda in the> advanced search, but there weren't any found.Correct. Her account has been removed.
kajbja at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 9
> > I searched for any posts authored by ronda in the> > advanced search, but there weren't any found.> > Correct. Her account has been removed.I wonder what took them so long.
hunter9000a at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 10

> "...expressions in the Java programming language that

> operate on boolean values are compiled to use values

> of the Java virtual machine int data type."

Well, if that's the case, then why can't I do...

int i = 4;

if (i) {

System.out.println("See? Now Java rocks like C :)");

}

kevjavaa at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 11
> Well, if that's the case, then why can't I do...Well, first you have to get past the parsing/type-checking phase ;-)
Hippolytea at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 12
> > Well, if that's the case, then why can't I do...> > Well, first you have to get past the> parsing/type-checking phase ;-)What about the warm liquid goo phase?
macrules2a at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...
# 13
Why did they delete ronda's account?I haven't seen her do anything shady around these forums.
maple_shafta at 2007-7-12 14:44:00 > top of Java-index,Java Essentials,Java Programming...