kevin saber

Greenhorn
+ Follow
since Mar 07, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kevin saber

I have followed the instruction of the Android docs, "Dev Guide ——>User Interface ——> Creating Menus——>Define Menus in XML".
But after creating "res\menu\options_menu.xml" and run the application, the result is as follow:


*The code about options_menu.xml is :
, saving correctly!

* The console displayed some error information as :


That is
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2010-05-10 22:06:33 - TestAndroid] Error in an XML file: aborting build.
[2010-05-10 22:06:34 - TestAndroid] W/ResourceType( 4020): Bad XML block: header size 261 or total size 17105092 is larger than data size 0
[2010-05-10 22:06:34 - TestAndroid] D:\kevin\kevinWork\TestAndroid\res\menu\options_menu.xml:1: error: Error parsing XML: no element found
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

How shoul this problem be resolved?


14 years ago
After creating resources in the directory res\values, and building them( using Eclipse 3.4) , the "R.java" file can't modify automatically.
What's wrong???
14 years ago
It seems that the AVD Gets faster after using it several times.
Thanks everybody!!!
14 years ago
When I test the application from Eclipse, it always takes me almost 10~15 minutes to see the result on AVD.
My OS: windows 7
CPU : Pentium D 805
RAM: 2G
SDK: java 6 + Android 2.1

Are there some ways to improve this situation?
14 years ago

Karthik Shiraly wrote:

kevin saber wrote:
But the expression "System.out.println("go on");" in line 14 of Code 1 is unreachable, neither. Isn't it?



Hi Kevin,

Your point is valid. From a human point of view, both programs behave the same way. A dedicated static code analyzer would have flagged the error in both.
But the normal java compiler is not such an advanced code analyzer, because code analysis is not its purpose.
It does it only to a reasonable extent and not more.
In the 2nd example, the throw is part of the same code block, so it's able to "understand" that line 14 will never reach.
But to extend this analysis to any method call in that block can become complicated very quickly for the compiler.
In this example, me() is part of the same file so it's possible to check it. But it might just well as have been part of another jar (as an inherited method), or it might be a method whose body would actually result in 100s of method calls. The compiler never knows. There are too many possibilities and analysis to such an extent will not only take too much time and resources, but also complicate the compiler design itself.
So compilers are designed to make such analysis only to a reasonable depth, to achieve simplicity. Hence, no error in example 1 (And thank heavens for that, else us programmers would be out of work! ).

Cheers
Karthik



It sounds really complicated. I hope this kind of question never comes out in SCJP test. T_T!
And thank you.

Devaka Cooray wrote:The usage of generic types and wildcard are different. Read this article to understand the usage of generic types. In particular,



wowo!!!
How detailed this material is!Thanks~thanks.hoho!!!
Really confuused!
Are they the same totally?
And What should I look out when using them?

Rufat Piriyev wrote:

this because line 13 in second code isn't reachable statement . The reason line 12



But the expression "System.out.println("go on");" in line 14 of Code 1 is unreachable, neither. Isn't it?
Please look at the two codes following :
(a nearly similar question from CertPal)

CertPal SJCP6 wrote:
Code 1:

---------------------------------------------------------------------------------------------------------------------------------------------------
Code 2:




Code 1 will compile, but Code 2 does‘t .
Aren't they really the same ? why the result is different?
still a little abstract...
But i will remember it .
Please look at two following codes:


and



Can somebody tell me how each code run and how one of them lead to stackoverflow error ?

Prithvi Sehgal wrote:In case of

A- It is creating an anonymous array. You cannot specify the dimension when you create an anonymous array. So statement A is invalid.
C- It is creating a two dimensional anonymous array and it is assigning the first array that is the 0 one to the one dimension array which
is perfectly legal. Because 2-D arrays are array or arrays.
E- has the same problem an anonymous array can't have dimensions mentioned.

Later is very well explained by harpreet.

Hope this helps,



Oh~~I see it. Thank you

Harpreet Singh janda wrote:It does not convert int[] to int[][].

A 2 dimensional array is as array of arrays.



code is assigning a one dimensional array to one dimensional array. int[][]{{1}}[0] is creating a two dimensional array and initializing the first dimension only then the code is using the [0] operator to get the array at 0th location and array will be one dimension array. So it is legal to assign it to one dimension array.


int[][] it3 = new int[]{0}[0][0]; is not legal because [0][0] will give us the element at that location. That element will be of type int and we can not assign an int to an array.



Thank you. I think i have caught it

Devaka Cooray wrote:Please QuoteYourSources and please UseAMeaningfulSubjectLine



Sorry for that