9, మార్చి 2015, సోమవారం

JAVA SITES IN TELUGU

All Java sites and Java related technologies sites. Java interview questions sites,jsf sites, core java sites,hibernate sites,struts sites,web services sites etc..
HIBERNATE SITES:
www.hibernate.org
www.roseindia.net/hibernate/index.shtml
www.developersbook.com/
www.mkyong.com/tutorials/hibernate-tutorials/
www.docs.jboss.org/hibernate/core/3.5/reference/en/html/tutorial.html
www.laliluna.de/.../struts-1-hibernate-integration-tutorial-en.html
www.javabeat.net/tutorials/19-what-is-hibernate.html
www.hibernatetutorial.com/
www.myeclipseide.com/documentation/quickstarts/hibernate
http://www.vaannila.com/hibernate/hibernate-tutorial/hibernate-tutorial.htm
www.viralpatel.net/.../tutorial-struts2-hibernate-example-eclipse.html
www.facestutorials.icefaces.org/tutorial/hibernate-tutorial.html
www.laliluna.de/articles/first-hibernate-example-tutorial.html
www.java-samples.com/showtutoriallist.php?...Hibernate...1
http://www.skill-guru.com/blog/2009/08/05/first-hibernate-tutorial-%E2%80%93get-hands-on-experience/
http://www.lulu.com/items/volume_62/1087000/1087191/3/print/Hibernate-Spring-Maven-Eclipse-Tutorial.pdf
http://en.wikipedia.org/wiki/Hibernate_(Java)
http://www.javabeat.net/articles/hibernate/1/
 
JAVA FORUMS:
 
WEB SERVICES SITES:
http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.6/tutorial/doc/index.html
www.developers.net/node/view/165
www.w3schools.com/webservices/default.asp
Comments
You do not have permission to add comments.

19, ఫిబ్రవరి 2015, గురువారం

Assertion:

Assertion is a statement in java. It can be used to test your assumptions about the program.
While executing assertion, it is believed to be true. If it fails, JVM will throw an error named AssertionError. It is mainly used for testing purpose.

Advantage of Assertion:

It provides an effective way to detect and correct programming errors.

Syntax of using Assertion:

There are two ways to use assertion. First way is:
  1. assert expression;  
and second way is:
  1. assert expression1 : expression2;  

Simple Example of Assertion in java:

  1. import java.util.Scanner;  
  2.     
  3. class AssertionExample{  
  4.  public static void main( String args[] ){  
  5.   
  6.   Scanner scanner = new Scanner( System.in );  
  7.   System.out.print("Enter ur age ");  
  8.     
  9.   int value = scanner.nextInt();  
  10.   assert value>=18:" Not valid";  
  11.   
  12.   System.out.println("value is "+value);  
  13.  }   
  14. }  

If you use assertion, It will not run simply because assertion is disabled by default. To enable the assertion, -ea or -enableassertions switch of java must be used.
Compile it by: javac AssertionExample.java
Run it by: java -ea AssertionExample
Output: Enter ur age 11
Exception in thread "main" java.lang.AssertionError: Not valid at AssertionExample.main(AssertionExample.java:10)
 

Where not to use Assertion:

There are some situations where assertion should be avoid to use. They are:
  1. According to Sun Specification, assertion should not be used to check arguments in the public methods because it should result in appropriate runtime exception e.g. IllegalArgumentException, NullPointerException etc.
  2. Do not use assertion, if you don't want any error in any situation.

17, ఫిబ్రవరి 2015, మంగళవారం








THIS IS THE PROGRAM WHICH WILL EXPLAIN ABOUT THE PROPERTIES CLASS IN JAVA.UTIL PACKAGE



import java.util.*;
public class Proper{
public static void main(String args[])
{
Properties p= System.getProperties();
p.list(System.out);
String course=System.getProperty("ramu");
System.out.println("NOW USER DEFINED PROPERTY IS STARTED");
if(course.equals("dayina@chirala"))
System.out.println(course);
else
System.out.println("UNKNOWN");
}
}


execution 
D:\Threads>java -Dramu=dayina@chirala Proper
-- listing properties --
PROPERTIENAME= VALUE
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:\Program Files\Java\jre1.8.0_31\bin
java.vm.version=25.31-b07
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
ramu=dayina@chirala
NOW USER DEFINED PROPERTY IS STARTED
dayina@chirala

A SIMPLE EXAMPLE ABOUT GENERICS IN JAVA EXPLAINS ABOUT TYPE SAFETY, TYPE CASTING AND POLYMORPHISM



import java.util.*;
public class Generics{

public static void main(String args[])
{

//generic version of ArrayList
ArrayList<String> l=new ArrayList<String>();
List<String> l2=new ArrayList<String>();
l2.add("list reference");
Collection<String> l3=new ArrayList<String>();
l3.add("collection reference");


//ArrayList<int> l1=new ArrayList<int>();
//List<Object> l4=new ArrayList<String>();
l.add("ramu");
l.add("dayina");
l.add("10");  //CE Gene.java:11: cannot find symbol l.add(10);//CEsymbol:   method add(int)  location: class ArrayList<String>1 error

System.out.println(l);
System.out.println(l2);

System.out.println(l3);

 //Collection(I)list(I) are the parent interfaces so they can hold the child references 
List<Integer> l5=new ArrayList<Integer>();
l5.add(100);
List<Integer> l6=new LinkedList<Integer>();
l6.add(101);
List<Integer> l7=new Vector<Integer>();
l7.add(102);
List<Integer> l8=new Stack<Integer>();
l8.add(103);
System.out.println(l5);System.out.println(l6);System.out.println(l7);System.out.println(l8);

}}


D:\Threads>javac Generics.java
 D:\Threads>java Generics
[ramu, dayina, 10]
[list reference]
[collection reference]
[100]
[101]
[102]
[103]

SIMPLE EXAMPLE ABOUT JAVA.LANG.OBJECT



class Student
{
int sno;
String sname;
Student(int sno,String sname)
{
this.sno=sno;
this.sname=sname;}

/*public String toString()
{ return "STUDENT ID IS  "+sno+"\n"+"SNAME IS "+sname; }*/
}
public class TestObject
{
public static void main(String ramu[])
{
Student s=new Student(100,"ramu@dayina");
System.out.println(s);
}}


Output:- before overriding toString() method jvm executing object class toString() by default
D:\Threads>java TestObject
Student@1db9742   ->   classname@hashcode

After defining by the user toString()
D:\Threads>java TestObject
STUDENT ID IS  100
SNAME IS ramu@dayina