Wednesday, 22 September 2010

My Quick Reference

Class with Static data which Returns as List

package demo.combobox.simple_combobox;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ShirtData {

private static List<String> colors = new ArrayList<String>();
private static List<String> sizes = new ArrayList<String>();



public static final List<String> getColors() {
return new ArrayList<String>(colors);

public static final List<String> getSizes() {
return new ArrayList<String>(sizes);

How to cast an Object to an int in java?

If you're sure that this object is an Integer :

int i = (Integer) object;

Or, starting from Java 7, you can equivalently write:

int i = (int) object;

Beware, it can throw a ClassCastException if your object isn't an Integer and aNullPointerException if your object is null.

This way you assume that your Object is an Integer (the wrapped int) and you unbox it into an int.

int is a primitive so it can't be stored as an Object, the only way is to have an intconsidered/boxed as an Integer then stored as an Object.

If your object is a String, then you can use the Integer.valueOf() method to convert it into a simple int :

int i = Integer.valueOf((String) object);

It can throw a NumberFormatException if your object isn't really a String with an integer as content.

Java Inner class example

import java.util.*;

public class SampleVM {

private List<MyData> names = new ArrayList<MyData>();

public SampleVM() {
names.add(new MyData("name 1",true));
names.add(new MyData("name 2",false));
names.add(new MyData("name 3",false));
names.add(new MyData("name 4",false));
names.add(new MyData("name 5",false));


public List<MyData> getNames() {
return names;
public class MyData{
String name;
boolean open;
public String getName() {
return name;
public void setName(String name) { = name;
public boolean isOpen() {
return open;
public void setOpen(boolean open) { = open;
public MyData(String name, boolean open) {
super(); = name; = open;


Hibernate Where in clause to Delete multiple items

public void deletePracticeAppMenu(List<Long> prAppMenuIDs, Long practiceID) {
String query = "delete from PracticeAppMenu where PrAppMenuID in (:appMenuIDs) and practiceID = :pracid ";
Query q = getCurrentSession().createQuery(query);
q.setParameterList("appMenuIDs", prAppMenuIDs);
q.setParameter("pracid", practiceID);


  1. Good efforts. All the best for future posts. I have bookmarked you. Well done. I read and like this post. Thanks. best mba colleges in punjab

  2. Microsoft office has a different version, and the entire version has the different setup file. Some of the version is Office 2013, Office 2016 and Office 365 etc. Go to and redeem your key. Office Com Setup is one of the most popular productivity programs around. If you have your product key handy, you don't even need a disc to start installing Office just visit office setup help. Norton is one of the most reliable antivirus providers in the market to download visit . There are multiple manufacturers making printers for home and office use with varied range as printer series per the need and affordability of different customers. Printer Tech Support. It has become one of the most useful computer hardware devices that allow people to convert computer generated typescript into a physical printed document.


Passing Parameter between two files using MVVM

This examples shows how to pass parameter between two zul screens. In this example, we are passing some parameters from the parent vm to...