Anastasia Sirotenko

Ranch Hand
+ Follow
since Jul 20, 2009
Merit badge: grant badges
For More
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 Anastasia Sirotenko

I try to load an xsl file with classLoader, but Test.class.getResourceAsStream("test.xsl") always returns null. Then i copied the test.xsl file to test.png - and that one works fine. Can anyone explain me how it can happen?

Here is the test case: two identical files with different extensions reside in the same package, and classloader works with different results:

The output is:
xsl: null

UPD: The problem found - i was lounching this from IDEA and it was misconfigured: Resource patterns setting included *png but didn't include *xsl
12 years ago
I believe it is enough to remember all checked exceptions that are mentioned in K&B book (in exceptions' chapter, in chapters on I/O and concurrency). Other than that exceptions will be given with hierarchy, like:

vineet walia wrote:it is not width try change argumnet 7 and then 7267 ?

It is width. You can call it "minimum width". If argument's width extends it, it is ignored. Try to put 010 instead of 01, see the difference.
Here what your method should look like:

public static <Declare new Generic type> Collection<Type of return value> getLongWords( Collection<Type of parameter> coll ){ }

now look what you've got:

<E extends CharSequence> - type declaration ok
Collection<E super String> - another type declaration? it is not the right place to declare new type where the return type should go
it would be legal to put here <? super String> though, as that is what type wildcard looks like
Collection<E> - type of parameter is ok, it was previously declared

<E> - type declaratin is ok
Collection<E extends Number> - one more type declaration where it should not occur
it would be legal to put here <? extends Number> though, as that is what type wildcard looks like
Collection<E> - valid parameter type, which was declared first.

PS. And don't forget that since you declared return type, you should return something from both methods...
Congratulations, keep moving!
14 years ago

Harry Henriques wrote:I just wanted to make sure that this isn't a Java 6 feature ONLY.

It is same for java 5.
by the way, you can get any older jdk and manage your IDE or OS to run them

Harry Henriques wrote:Thanks for your reply, Sebastian. But the code below compiles and runs just fine. I instantiate an implementation of interface Range and an implementation of interface Grassland. The output is below in red.

You not clearly understand what means "can not extend more then one class or implement more then one interface"
The extended class can implement lots of interfaces itself, or implemented interface can extend from lots of other interfaces. Just like it shows in your code.
You certainly can do this:

But you cannot do something like this:
Just gave the exam, got 90% and feel good 8]
Want to thank Kathy Sierra and Bert Bates for their book and Devaka for a great ExamLab simulation.
And of course thank to all you ranchers who helped me to clear some topics and those who asked questions which i got to clear too.

14 years ago
it means that when your code is like

internaly it goes like

The values that contained in the wrapper don't change, when some operations are made on them, it means new wrapper objects are created and assigned to you wrapper references.

krishna Mohan Athota wrote:
An abstract "Inner Class" is also an abstarct element. So i beleive we should modify the class outer also with abstract modifier. why we are not geeting the compilation ERROR?

Inner classes are not like methods, the are classes. When you declare abstract inner class, you can declare its subclasses in the same outer class, and implement different inner class realizations, and use all of them in your outer class as needed. You can even have abstract private inner class, since all it's subclasses can be implemented inside the same outer class.
Remember you cannot have abstract private methods, cause abstract methods are all due to overriding in some descendant classes.

NullPointer comes from line 8, where you try to instantiate gb1.g.g , tho gb1.g is null after line 7
3 objects:

Nitish Bangera wrote:labelled break can be used for any code block but the necessary requirement is it should break the codeblock with that label. labelled continue can only be used for loops with the same label.

Thank you for clearing, Nitish and Ankit, got it 8)

Sebastian Janisch wrote:The break statement has no effect.
Note that you are labeling an if statement not a loop (also why continue won't compile).
As your code stands it does thw following.

Your code breaks out of an if statement that would have ended anyway.

I tried this after finding the illustration: (source)

And it breaks fine from while loop, which is actually labeled, it prints 8, then breaks, then just for loop procedes. The if statement stands instead of {} here, i assume.