Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Radiya Sojitrawala

Greenhorn
+ Follow
since Aug 06, 2005
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 Radiya Sojitrawala

hi,

could you please give the name of the book from Sun that you followed.

thanks
15 years ago
Is this correct and if yes how/why? Why would we not need 'new' to allocate memory to d?

Double d = Double.valueOf("3.14");

thanks
radiya
No I mean the very line
String d = "\u000d"

here (as pointed out by Earnest before) unicode is translated first. So the unicode \u000d gets translated to a newline or return character.
Now its equivalent to String d = "newline" and there is no escape sequence(\).. so the error
For the first bit pattern 1011 0001
note that this is a negative number and we are doing a signed right shift. In a signed right shift, we replace the MSBs(most significant bits whch are the leftmost bits) by the sign bit

so 1011 0001 >> 2
step1:_ _ 10 1100 // shift to right by 2
step2:1110 1100 // fill MSBs with sign bit which is one here

1110 1100 is a negative no because of 1 in the MSB.

-------------------------------------------------------------------

For the bit pattern 0010 0001

I think the answer should be 0000 1000 and not 0000 10101
QUOTE] Unicode escapes are turned into the characters they represent very early in thr translation process. The \u000a in the comment gets turned into a newline, so that the line ends up as ...


I used the multi-line comment and it does not give an error then .. so it does not translate to unicode now .. wierd!!
Its the same reason.

the unicode escape sequence is translated earlier..

the \u000d is equivalent to return and it is ranslated to it .. but as there is no escape for return we get an error

HTH

Radiya
class A {
public static void main (String[] args) {
String a = "\n"; // 1
String b = "\r"; // 2
String c = "\n"; // 3 \u000a = new line
String d = "\u000d"; // 4 \u000d = return
}}


this code was supposed to give an error only on line 4. but it also gives an error on line 3 in the comment on "=" saying illegaL start of expression.

any clues?

Radiya
I opened my .class file in notepad but i dont see cafebabe as the first 4 bytes. what do i need to do?

TIA
Radiya
15 years ago
Hi,

I am confused too..

I expected this
i = i++;
=> i = (i++); // precedence of post increment over assignment
=> i = (0++); // replace i by 0
=> i = (0 + 1);
=> i = 1; // ???

please can someone explain why is this wrong?

TIA
Radiya
Hi,

I am studying for the SCJP and the K&B mentions that Math.abs() does not reurn a non-negative value in two cases.

I found that one case is when Math.abs is called on the Integer.MIN_VALUE.

Anyone any idea on the second case? or more cases?

TIA
Radiya
Hi,
I would like to join the study group. I ahve just started with teh K&B book on SCJP 1.4 and here.

Please add me to your list.

thank you
Radiya