This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Emrik SjöKa

Greenhorn
+ Follow
since Sep 10, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emrik SjöKa

Campbell Ritchie wrote:

Emrik SjöKa wrote:Hi, I'm studying Java for ocajp 8 exam.. . .

I shall now challenge you. Is that an infinite loop or not?



Thanks for your challenge

This is an infinite loop, because that loop in the main method and that does not return anything. As you know java application start with main method. This method is static and a static method can't be called by any instance (it may be called but static methods belongs the its own class) and main is a non daemon threat (used by jvm as garbage c.). When command line argument pass into String arrray non - daemon begins to execute in this situation there is no way to exit bc deamon threat keep going to run.


Emrik SjöKa wrote:Hi Mauricio,
You have already gotten answers for your question but i would like to add a bit more info.
If you'll be use Binary, Octal or Hexadecimal numbers you should be aware also some points.

You might know binary system use 0 and 1(base 2). Same rules are valid as Liutauras Vilda's mentioned.
You can't use underscore beginig or ending ex;
int i = 0b_111; // won't compile
int i1 = 0b1_11 // compile

Octal number uses between 0 to 7 (base 8)
[strike]int i2 = 0_123; //  compiles
int i3 = _0123;  // won't  compile

Hexidecimal num uses 0 to 9 and letter A or a to F or f ( A is 11 B is 12 ... 15 is F)
int i4 = 0x_9A; // won't compile
int i5 = 0x9_A; // compiles

By the way do not use underscore for object arguments
ex; Integer i = new Integer("123_456"); // NumberFormatException

2 years ago
Hi Mauricio,
You have already gotten answers for your question but i would like to add a bit more info.
If you'll be use Binary, Octal or Hexadecimal numbers you should be aware also some points.

You might know binary system use 0 and 1(base 2). Same rules are valid as Liutauras Vilda's mentioned.
You can't use underscore beginig or ending ex;
int i = 0b_111; // won't compile
int i1 = 0b1_11 // compilse

Octal number uses between 0 to 7 (base 8)
int i2 = 0_123; // won't compiles
int i3 = _0123;  // compiles

Hexidecimal num uses 0 to 9 and letter A or a to F or f ( A is 11 B is 12 ... 15 is F)
int i4 = 0x_9A; // won't compile
int i5 = 0x9_A; // compiles

By the way do not use underscore for object arguments
ex; Integer i = new Integer("123_456"); // NumberFormatException
2 years ago
I might be making a wrong, to posting the question but there is the only way to express my question correctly.
Here is the question.
Hi, I'm studying Java for ocajp 8 exam.
I answered a question and I'm quite sure that is infinite loop (or missing info). I've asked my question to author of book (maybe I should have asked on forum first).
Anyway i took a quick and polite response to my message;
" It's not in error. Please post in the OCA forum why you think it is wrong (or don't understand the answer) and I or someone else will reply with more detail. "
So could you please tell me what is the output of the below code?
As I wrote, I answered;
"This is infinitie loop".
The right answer is "aa".
How can  the correct answer be "aa", I really do not get that :/
Thanks for opinions & answers.
 

What is the fallowing code code output?

 0- package xxxx;
 1-   public class Abcd{
 2-     public static void main(String[] args){
 3-         for(int i= args.length; i>=0; i++)
 4-           System.out.println("args");
 5-   }
 6- }