Feed on
 Posts
 Comments
Java Beans dot Asia

Just a few simple tutorials …

Category Archive for 'design patterns'

Consider the following case of inheritance: public class Parent { public Parent() { getValue(); } public void getValue() { } } public class Child extends Parent { private final Integer integer; public Child() { integer = new Integer(888); } @Override public void getValue() { System.out.println(integer); } } Question: What would the following program print, why? [...]

Read Full Post »

Consider the following case of inheritance: public class ExtendingHashSet<E> extends HashSet<E> { private int counter = 0; public ExtendingHashSet() { } @Override public boolean add(E e) { counter++; return super.add(e); } @Override public boolean addAll(Collection&lt;? extends E&gt; c) { counter += c.size(); return super.addAll(c); } public int getCounter() { return counter; } } Created instance: [...]

Read Full Post »

Few days ago I was searching for a solution to the problem I’ve encountered – I needed to prevent a third party page to break out of iframe inside a web page of my web application. For people who are not closely familiar with JavaScript, the following JS snippet will make it more clear how [...]

Read Full Post »

I came across an interesting article that discusses today’s application developers making extensive use of different frameworks in their applications. This is the writer’s opinion: …Todays projects are over bloated from the use of frameworks that dont really produce a real benefit. Developers spend around 75% of their time just on set up and configuration… [...]

Read Full Post »

Question: The following program returns result “1″, which indicates that first Integer value is greater than the second, why? import java.util.*; public class Example { public static void main(String[] args) { System.out.println(&quot;Result: &quot; + naturalOrder.compare(new Integer(90), new Integer(90))); } private static Comparator&lt;Integer&gt; naturalOrder = new Comparator&lt;Integer&gt;() { public int compare(Integer first, Integer second) { return [...]

Read Full Post »


Page 1 of 212