Atul Shukla

Ranch Hand
+ Follow
since Oct 09, 2006
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 Atul Shukla

Thank you Ranchers!!
17 years ago
i too agree with cameron ,
people say it easy because they put some efforts to pass exam, and efforts turn out in these sayings,

and you also saying it is not hard, that is true because you have put efforts and you are a SCJP now!!
cheers!!
17 years ago
Hi ranchers!!
just taken the test today and
I scored 83% in SCJP5 310-055

I want to thank Javaranch for providing such a nice platform to discuss all Java related Stuff.

these are details of score
Declarations,Initialization and Scoping.........100%
Flow Control....................................100%
API Contents.....................................70%
Concurrency......................................75%
OO Concepts......................................70%
Collections / Generics...........................90%
Fundamentals.....................................72%

Thanks again -JavaRanch!!

and Best Wishes to all upcoming condidates for the exam....
[ November 11, 2006: Message edited by: Atul Shukla ]
17 years ago
thank you so much Burkhard!! that was a very nice explanation..

i am really not able to get into that horrable language Specification!!

Originally posted by Saurabh Vyas:

Thus compiler is showing ambiguous method call error during compilation of our original problem. B�cos compiler is confused as to which type of array it should convert the arguments of vararg method.


class Vararg {
static void vararg(long ... x)
{ System.out.println("long..."); }
static void vararg(Integer ... x)
{ System.out.println("Integer..."); }
public static void main(String [] args) {
int i = 5;
vararg(5,5);
}
}


?

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

Thanks
Sanjeev KS
Posts: 60 | Registered: Nov 2006 | IP: Logged
Jae Stryker
greenhorn
Member # 137135

posted November 07, 2006 01:46 AM Profile for Jae Stryker Send New Private Message Edit/Delete Post Reply With Quote It doesn't compile.

However I've changed the code slighty to try and help you along

code:


class Vararg {
static void vararg(String ... x)
{ System.out.println("String..."); }
static void vararg(Integer ... x)
{ System.out.println("Integer..."); }
public static void main(String [] args) {

int i = 5;
vararg(i,i);

String testOne = "TestOne";
String testTwo = "TestTwo";
String testThree = "TestThree";
//vararg(testOne,testTwo,testThree); Now there is no Error
}
}

I agree with Saurabh as this program dosen't produce any error , if we do not attempt to call these ambiguous overloaded methods
on calling Thread.yield(), thread retains the lock ...as Thread.sleep() retains ?
both retain lock ?
hi! jothi shankar
thanks for the nice little tutorial
hey Ramkumar i couldn't get that implications from hashcode values...

if .equals results in true then hashcode must be equal
if hashcodes are equal then there is no requirement for equals to be true..
if hascodes are not equal then equal must be false


please explain
or eg : "Atul"=="Atul" returns true
or
String s="atul";
"atul"==s return true
but
String s="atul";
String h="ul";
String i="at"+h; s==i returns false
or
String s="atul"; // (A)
String h="";
String i="atul"+h; s==i returns "false" //"one more thing"
but
String s="atul";
String h="ul";
String i="atul"+"";s==i returns true
and
String s="atul";
final String h="";
String i="atul"+h; s==i returns "true" //(compare it with (A))
some typos in above answer so read this version--

first do know this-
Integer i1=1;
Integer i2=1;

here i1==i2 returns "true" and i1!=i2 returns "false"
but
Integer i1=1000;
Integer i2=1000;
here i1==i2 returns "false" and i1!=i2 returns "true"

here is the basic rule Two instances of the followin wrapper objects will always be == (means return true) when the "primitives "values" " are same

1. Byte
2. Boolean
3. Character from \u0000 to \u007f
4. Short and Integer from -128 to 127

NOW for Strings
== return true when two strings been compared are either literals or compiled time constants but not created usin new keyword and one more thing explained later;

for eg : "Atul"=="Atul" returns true
or
String s="atul";
"atul"==s return true
but
String s="atul";
String h="ul";
String i="at"+h; returns false
or
String s="atul"; // (A)
String h="";
String i="atul"+h; returns "false" //"one more thing"
but
String s="atul";
String h="ul";
String i="atul"+""; returns true
and
String s="atul";
final String h="";
String i="atul"+h; returns "true" //(compare it with (A))
one more thing that i promised to tell later ..u can infer through (A)

now coming to question

String s1="Priyam";

String s3="yam";
String s2="Pri" + s3;
System.out.println("s1==s2:: " + (s1==s2)); //Output false

String is returning false as explained in (A)

and for Wrapper Integer
Integer int3 = 5;
Integer int5 = 2;
Integer int4 = 3 + int5;
System.out.println("int3==int4:: " + (int3==int4)); //Output true

you can infer from the explanation given on the top

There is nothing to compare in functionality of == in String and Integer

== in String works for String "literals" and == in Wrapper for "primitive "values""

hope this much helped
Regards
-Atul
first do know this-
Integer i1=1;
Integer i2=1;

here i1==i2 returns "true" and i1!=i2 returns "false"
and
but
Integer i1=1000;
Integer i2=1000;
here i1==i2 returns "false" and i1!=i2 returns "true"

here is the basic rule Two instances of the followin wrapper objects will always be == (means return true) when the "primitives "values" " are same

1. Byte
2. Boolean
3. Character from \u0000 to \u007f
4. Short and Integer from -128 to 127

NOW for Strings
== return true when two strings been compared are either literals or compiled time constants but not created usin new keyword and one more thing explained later;

for eg : "Atul"=="Atul" returns true
or
String s="atul";
"atul"==s return true
but
String s="atul";
String h="ul";
String i="at"+h; returns false
or
String s="atul"; // (A)
String h="";
String i="atul"+h; returns "false" //"one more thing"
but
String s="atul";
String h="ul";
String i="atul"+""; returns true
and
String s="atul";
final String h="ul";
String i="atul"+h; returns "true" //(compare it with (A))
one more thing that i promised to tell later ..u can infer through (A)

now coming to question

String s1="Priyam";

String s3="yam";
String s2="Pri" + s3;
System.out.println("s1==s2:: " + (s1==s2)); //Output false

String is returning false as explained in (A)

and for Wrapper Integer
Integer int3 = 5;
Integer int5 = 2;
Integer int4 = 3 + int5;
System.out.println("int3==int4:: " + (int3==int4)); //Output true

you can infer from the explanation given on the top

There is nothing to compare in functionality of == in String and Integer

String works for String "literals" and Wrapper for "primitive "values""

hope this much helped
Regards
-Atul
Hi! ranchers
i have a little question-
if i synchronize static block on instance it runs fine, but is that different from getting lock of "Class" object as static methods holds by default for eg:
class a{
static void o() {

synchronized(new a()){ // 1
}

}

}
i mean to say am i getting lock on class represented by newly created instance at line 1.

Thanks in advance!
Above Limk is very helpful, thanks Wise!!
Static method synchronization not gives you object lock rather gives you lock for Class object running in JVM ...because static methods does not have this refrence and so can not give you object lock for current instance...

-Atul