Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Prince Chauda

+ Follow
since Feb 13, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prince Chauda

Why this code produces compile time error - exception is never thrown in body of corresponding try statement

while this one doesn't

13 years ago

Peter Hsu wrote:Hi

Can someone give me a few rules of when casting/autoboxing can happen and when couldn't it?

I am confused.........

In java , in case of primitives any smaller data type can be assigned to greater one .This is called widening.
But for narrowing you have to make a cast if the assigned value is greater than its size limit.

For rest of the things refer "Kaithy Sierra" for SCJP.
13 years ago

Rob Prime wrote:And even if we ignore Strings, double / float (in general: floating point) addition may do some rounding between calls. Therefore, a + b + c may be slightly different from a + c + b.

There is no such type of problem of rounding because " + " operator will do automatic widening according to its operands and convert both in the bigger one.

for example ;
13 years ago
While providing a reference of a super-class to the object of the sub-class we are simply
decreasing the usability of that object because it can not call the methods declared only in its own class.
So what are the benefits (other than tight encapsulation and loose coupling ) of this feature of java ?
13 years ago

Rob Prime wrote:Labelled statements should only be used with nested loops, where an inner loop needs to break or continue one of the outer loops. For instance:

Since labels can be applied to any statements except before declaration , but break and continue should be within a loop. So my question was that what is the benefit of of such labels which are outside the loop or before any other statements ?
13 years ago

Campbell Ritchie wrote:Two possible answers:

  • No use at all. They were leftovers from C/C++ which ought to have been deleted from the language in its infancy.
  • You can precede the name of a label by the keywords break and continue
  • Somebody else may provide different opinions.

    You can also precede a label with the keyword case, but that is something different.

    Thanks for your opinions ... still waiting for more...
    13 years ago
    We can use labels at anywhere except before the declaration , but without a "goto" statements we can never call those labels.
    Then what is the use for such labels ?
    13 years ago

    Vierda Mila wrote:Dear all,

    I have 2 classes and each class need object from each other as instance member. I have tried to compile these 2 classes and it always fail and compiler tell that cannot found symbol. it make sense because I fail to compile either class A or B.

    My question is how to compile class like these according these 2 classes inside in same package, thank you for any kind help.


    The thing happening to this code that one class can't found other is due to the classpath.
    Since neither of the file was compiled hence the directory having name "com" will not be there and thus your import statement will not work.

    You can try this.

    > If you want to compile then put in "com" directory and use the following code for compilation.

    This code will also compile
    but this will put your B.class in the current directory. Hence it will problematic in future so use this code for best result.

    13 years ago