File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some questions for newcomer as ME.Pls help ME.

 
Van Cam
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Van Cam
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very very much
Regards
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Van Cam
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20823
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic