Muhammad Khojaye

Ranch Hand
+ Follow
since Apr 12, 2009
Merit badge: grant badges
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Muhammad Khojaye

My advice for you is to SearchFirst. And I am sure, you will get many valuable replies for your questions .
11 years ago
Not sure since there are not enough information.
Anyway, getClassLoader().getResource() searches relative to the classpath root. If you are trying to search relative to .class file, try getClass().getResource(). Not sure but still hope it might help.
11 years ago
You're always welcome
11 years ago
If I am not sure about return type of function, then i might not clear what exactly I need. When designing function, it is important we should know what are the pre-condition before calling function and what client will expect after calling this. This will yield the correct method signature.
Also discuss with team member who will use this function and what they expect after calling this will help.

Regarding static, check whether it make sense to call this function without creating an object first. If its ok then it might be your usecase to define static. I hope it helps.
11 years ago

Campbell Ritchie wrote:

Muhammad Khojaye wrote: . . .
String is immutable not final, which means that you cannot alter them once create. So, in this case, two new instance will be created.

That is at best confusing. The String class is in fact marked final. What you mean is that the String reference in the code posted is not final, which means it can be reassigned.


At simply, immutable and final are very different, not sure about the confusion. The class is final which is very well fine for me to make it immutable.

11 years ago

sekhar kiran wrote:iam asking separately about overloading and overiding,


I am not sure what you are asking about here? Overloading and Overriding occur in method invocation, in example here, you are using simply object instance.

sekhar kiran wrote:i know the basic examples ,but what kind of situation we use them,ok but string is final right,so it cannot change their values


String is immutable not final, which means that you cannot alter them once create. So, in this case, two new instance will be created.
Check this also. Hope it helps.
11 years ago

Vivek Raj wrote:
A new thing for me. Thank you for modifying the code to make it more tricky.


You are welcome.

Vivek Raj wrote:
This means that private Super methods can be called on Sub object, provided the calling method is in super class? Am I correct?


Private method cannot be called directly from object of subclass since it can't be overridden. In the example, public printSuper method has been called of base class which implicitly invoke the private method. I hope it helps.
Private methods never overridden as Sidharth mentioned. I have tried to modified your example, run and see what happens,
write a for loop which examines each object in the list and returns the one with the right lotNumber, or null if isn't found.
@ps, Map is better structure for this.
11 years ago
According to Wiki

A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.


Proxy can be useful for accessing to large files or graphics. By using a proxy class, you can delay loading the resource until you need data from that. Without the concept of proxy class, an application can be slow and less responsive. Hope it helps.
11 years ago
You know that interface always refer to concret instance (dynamic binding) and every instance IS A object. Hope it helps.

It seems for values ranging from -128 to 127 i==i1 is true. but for others not


Just to add, in JDK 1.6, this range is not fixed and you can even override the cache range and configure a highest value for cache.
not sure but they might refer to Dynamic Binding?
11 years ago
Winston answer is already very explanatory and clear . Just to give you an small example regarding why we not catch Exception directly, consider below code,

this code will catch every exception that will throw inside try block. It might be the case that you don't want to handle every error, for instance "OutOfMemory" error,

now, consider below sample code,
now suppose if you are trying to open a file but it doesn't exist, you will catch it and may create any default file or blank file.
11 years ago