As much as i was convinced about it, i always got confused about this. Some useful links that would clarify :
http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
Wednesday, November 3, 2010
Thursday, August 5, 2010
How to determine the OS from JAVA..
http://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java
Wednesday, June 16, 2010
Abstract classes in JAVA..
Can abstract classes exist in JAVA without any abstract methods ?
The answer is yes. It made me curious as to why it was made technically possible in JAVA, while in C++ it is not the case [An abstract class must contain at least one pure virtual function ].
While it is a rare thing to happen and such a design should always be questioned to see if it is the right thing to do, one specific case where it is justified could be :
The abstract class partially implements an interface, with the intention that its subclasses must complete the interface. To take a slightly contrived motoring analogy, a
from http://www.codestyle.org/java/faq-Abstract.shtml#whynoabstract !
The answer is yes. It made me curious as to why it was made technically possible in JAVA, while in C++ it is not the case [An abstract class must contain at least one pure virtual function ].
While it is a rare thing to happen and such a design should always be questioned to see if it is the right thing to do, one specific case where it is justified could be :
The abstract class partially implements an interface, with the intention that its subclasses must complete the interface. To take a slightly contrived motoring analogy, a
Chassis
class may partially implement a Vehicle
interface and provide a set of core methods from which a range of concrete Vehicle
types are extended. Chassis
is not a viable implementation of a Vehicle
in its own right, so a concrete Car
subclass would have to implement interface methods for functional wheels, engine and bodywork. from http://www.codestyle.org/java/faq-Abstract.shtml#whynoabstract !
Sunday, June 13, 2010
Tail Recursion..
Was going through http://saicharan.in/blog/2010/05/binary-search-tree/ when I landed on tail recursion concept.
Have seen code like this before, but have not really noticed the difference between recursive and tail recursive code.
Tail Recursive code brings in lot of efficiency by drastically reducing the amount of stack space used. look up http://en.wikipedia.org/wiki/Tail_recursion !
Have seen code like this before, but have not really noticed the difference between recursive and tail recursive code.
Tail Recursive code brings in lot of efficiency by drastically reducing the amount of stack space used. look up http://en.wikipedia.org/wiki/Tail_recursion !
Thursday, June 10, 2010
Garbage Collector in C++..
Why isn't there a garbage collector in C++, or why hasn't been added... this sure makes a interesting topic to know more about - here i found a fair explanation on the subject.
http://stackoverflow.com/questions/147130/why-doesnt-c-have-a-garbage-collector
http://stackoverflow.com/questions/147130/why-doesnt-c-have-a-garbage-collector
Wednesday, June 9, 2010
Floating Point Arithmatic..
Did you ever face something like this : X, and Y are two floating point numbers. You print their values and they are exactly same. and then you write a simple logic like this..
if(x!=y) {
printf("x and y are not equal) ;
}
and it prints that x and y are not equal ;-) Apparantly it happens often. and if you wondered why
the following links might help you.
Its all got to do with floating point numbers..
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
http://stackoverflow.com/questions/588004/is-javascripts-math-broken
http://dlc.sun.com/pdf/800-7895/800-7895.pdf
if(x!=y) {
printf("x and y are not equal) ;
}
and it prints that x and y are not equal ;-) Apparantly it happens often. and if you wondered why
the following links might help you.
Its all got to do with floating point numbers..
http://www.cygnus-software.
http://stackoverflow.com/
http://dlc.sun.com/pdf/800-
Tuesday, June 8, 2010
what is serialVersionUID ?
Everytime you write a class that implements serializable interface the IDE shows a warning asking to add serialversionUID, I wondered why couple of times but looked it up to find the reasons..
Below is a good link that explains why... the point to note is serialVersionUID is an exception to the rule that “static fields don’t get serialized”
http://www.javablogging.com/what-is-serialversionuid/
Below is a good link that explains why... the point to note is serialVersionUID is an exception to the rule that “static fields don’t get serialized”
http://www.javablogging.com/what-is-serialversionuid/
Monday, May 24, 2010
Memory leaks in JAVA..
Whenever question was asked about Memory management in JAVA (vs) Memory management in C++, the only thing I knew of is that
- in C++, memory leaks can occur and programmer needs to take care of them by writing cleanup code. and there is also a problem of dangling pointers.
- Clearly in JAVA, garbage collector takes care of memory management, in the sense, it cleans up all the objects to which no references are left. Clearly problem of dangling pointers is addressed. But Is it the same case with Memory leaks ?
There is more to memory leaks in JAVA - some good links.
http://www.ibm.com/developerworks/rational/library/05/0816_GuptaPalanki/
http://jb2works.com/memoryleak/index.html
http://jb2works.com/memoryleak/topfive.html
- in C++, memory leaks can occur and programmer needs to take care of them by writing cleanup code. and there is also a problem of dangling pointers.
- Clearly in JAVA, garbage collector takes care of memory management, in the sense, it cleans up all the objects to which no references are left. Clearly problem of dangling pointers is addressed. But Is it the same case with Memory leaks ?
There is more to memory leaks in JAVA - some good links.
http://www.ibm.com/developerworks/rational/library/05/0816_GuptaPalanki/
http://jb2works.com/memoryleak/index.html
http://jb2works.com/memoryleak/topfive.html
Sunday, April 25, 2010
System.getproperty()
From http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html
System.getproperty() gets the system property specified by the key, also there is a System.getproperty(String key, String def) where default value can be specified. Helps while setting constants in JAVA program with some default values.
System.getproperty() gets the system property specified by the key, also there is a System.getproperty(String key, String def) where default value can be specified. Helps while setting constants in JAVA program with some default values.
Subscribe to:
Posts (Atom)