wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Some questions for newcomer as ME.Pls help ME. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Some questions for newcomer as ME.Pls help ME." Watch "Some questions for newcomer as ME.Pls help ME." New topic
Author

Some questions for newcomer as ME.Pls help ME.

Van Cam
Greenhorn

Joined: Aug 05, 2006
Posts: 13
I have some questions of foolish.Pls help me.I am a newbie.
1-when i declaire for instance:

Why ???
2-Why I see that have an type decalire of array following.

Why not declaire follow???

Pls compare two declaires type for me.
Thanks a lot.
PS
Pls Tutorial detail for me because I am not good in IT major so sorry for my stupid.
Regards. :roll:
[ August 19, 2006: Message edited by: Nguyen Van Cam ]
Sanjaya Sugiarto
Ranch Hand

Joined: Mar 25, 2004
Posts: 229

char will fit only in unsigned 16 bit range (0-65535). If you assign 70000 to char than it is out of char range (possible loss of precision). The same goes if you assign it to -98. Solution: either you assign to bigger literals like int or cast it (cast: in simplest word you said to compiler: "Stop whinning me. Just do what I said. I know exactly what I'm doing!")



Why not declaire follow???


Both are legal declaration of arrays. Either String[] test[] or String[][] test is legal. It is advisable to write String[][] test though. It is more readable.


<a href="http://www.wi.hs-furtwangen.de" target="_blank" rel="nofollow">Business Information Technology - Hochschule Furtwangen University, Germany</a>
Van Cam
Greenhorn

Joined: Aug 05, 2006
Posts: 13
Thanks you very very much
Regards
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
"ecard104",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with illegal display names get deleted.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Van Cam
Greenhorn

Joined: Aug 05, 2006
Posts: 13
Yes, I will be correct it now, But I would to ask some questions , Because
"Nguyen Van Cam" is my real Name and "ecard104" is my nick name so when I register in this forum , I was selected real name to display in the Forums,
I have forgotten choose nickname when Display, so I have correct it.
If this is degine of this Forum then I correct it now But I still want to display is my nickname when I register, Sorry for my disturb .
[ August 21, 2006: Message edited by: Nguyen Van Cam ]
Van Cam
Greenhorn

Joined: Aug 05, 2006
Posts: 13
I have next question!
As I known , the declaire follow is incorrect
int[] mang = new int[];
This will is error because JVM need is a size to allocate in the heap
So I must be declaire follow.
int[] mang = new int[5] ;
But I don't understand why I declaired follow is legal
int[][] mang= new int[3][];
Why the second bracket needn't value then JVM still accept this declaire???
Thanks in advance.

[ August 21, 2006: Message edited by: Nguyen Van Cam ]
[ August 21, 2006: Message edited by: Nguyen Van Cam ]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18753
    
  40

But I don't understand why I declaired follow is legal
int[][] mang= new int[3][];
Why the second bracket needn't value then JVM still accept this declaire???


Java doesn't really have multidimension arrays -- it supports them by using arrays of arrays. If the second (bracket) value was provided, Java will not only create an array object to hold all the arrays, but it will also create the many array objects for the integers as well.

If the second value is not provided, then only the array object (that holds the array of ints) is instantiated -- all the array elements of this array will be set to null.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some questions for newcomer as ME.Pls help ME.