This week's giveaway is in the Beginning Java forum.
We're giving away four copies of Bad Programming Practices 101 (e-book) and have Karl Beecher on-line!
See this thread for details.
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

saurabhthard aggarwal

Greenhorn
+ Follow
since Nov 20, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by saurabhthard aggarwal

Hi All

I'm trying to create a mobile application

I want to know the complete hardware and software requirements for the application.

example :which and how many servers would be required.(server configurations in details)
what are the S/W that would be required.
and any other requirements


The application is this
number of sales person would have this mobile application on the field
the sales person must be able to enter some basic info about interested clients which should be updated in the DB for further use.
should work in both cases Offline as well as online



Please reply as soon as possible

7 years ago
Hi all


I'm setting a date in java class and i want to convert it into xml georgian format in a single line
.
is there any method available,how do i solve this problem.

I have this code with me


XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xgc.setYear(1985);
xgc.setMonth(12);
xgc.setDay(17);

xgcCopy = DatatypeFactory.newInstance().newXMLGregorianCalendar(xgc.toXMLFormat());




please reply
I'm a fresher beginning to learn frameworks

can anybody tell me what is a framework used for in detail .

what is the difference between STRUTS & HIBERNATE & its individual uses & benifits.

thanks
7 years ago
can someone please explain me concept of interrupt(), interrupted()and isInterrupted() ,its use
please explain JOIN method in detail

what do we mean that one thread cannot tell another thread to block/sleep or wait

What is the DIFFERENCE between a THREAD and an OBJECT

Please explain with an example
Give me a Complete ,Simple example on Assertions

expression1 and expresssion2 explain the difference.
Yes it is right that instance blocks are copied inside the construtor, but my question is that why do we require constructor when we can give initial value inside instance initialisation block
According to K&B SCJP 6 Collections.sort() method will call compareTo() of comparable interface.
Input of the program is unsorted.

Output of the program is sorted.

Do you have any idea of how compareTo() is used inside sort() method.
Why do we need constructors when we can initialize variables in INSTANCE INTIALIZATION block
Is it just because we can over load constructors and not overload INSTANCE INTIALIZATION block .
//PLEASE EXPLAIN TO ME WHICH IS THE CALLED OBJECT AND WHICH IS THE CALLING OBJECT ,WHY

/*WHEN COMPARETO () METHOD IS CALLED FOR ADDING THE SECOND ELEMENT IN THE TREESET WHICH OBJECT VALUE IS COMPARED TO WHICH OBJECT VALUE.

/*WHEN COMPARETO () METHOD IS CALLED FOR ADDING THE SECOND ELEMENT IN THE TREESET WHICH OBJECT VALUE IS COMPARED TO WHICH OBJECT VALUE.
*/



/* WHEN IS COMPARETO METHOD CALLED, WHY DO WE NEED TO PUT ELEMENTS OF TREESET IN TO AN OBJECT ARRAY AND THEN TYPE CAST IT.
*/


import java.util.*;

class Comparable1
{
public static void main(String[] args)
{
TreeSet ts1=new TreeSet();

ts1.add(new Student("Saurabh","Thard",100,0.1));

ts1.add(new Student("Sachin","Tendulkar",200,0.01));

ts1.add(new Student("Prannoy","Roy",300,03.03));

ts1.add(new Student("Barkha","Dutt",400,04.4));

ts1.add(new Student("Vikram","Chandra",500,5.05));

Object [] studArray=ts1.toArray();

Student s;

for(Object obj:studArray)

{
s=(Student) obj;

System.out.printf("NAME = %s %s STUDENT ID =%d GPA=%.1f \n",s.fname(),s.lname(),
s.StudentID(),s.gpa());

}
}
}
class Student implements Comparable
{

String fname;
String lname;
int studentID;
double gpa;

public Student(String fname,String lname,int studentID,double gpa)
{

if(fname==null || lname==null || studentID==0 || gpa==0.0)

{
throw new IllegalArgumentException();
}

this.fname=fname;
this.lname=lname;
this.studentID=studentID;
this.gpa=gpa;
}

public String fname()
{
return fname;
}

public String lname()
{
return lname;
}

public int StudentID()
{
return studentID;
}

public double gpa()
{
return gpa;
}

public int compareTo(Object o) //OVER-RIDING COMPARETO SINCE IT IMPLEMENTS COMPARABLE.
{
double f= gpa- ((Student)o).gpa;

if(f==0.0)
return 0;

else if(f<0.0)
return -1;

else
return 1;
}
}



please give me SIMPLE ,COMPLETE example of Comparable interface.Also its main features.