File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the output and Why

 
Indravadan T Patel
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.util.Date;

public class Example {

public static void main(String args[]) {

Date d1 = new Date (99, 11, 31);

Date d2 = new Date (99, 11, 31);

method(d1, d2);

System.out.println("d1 is " + d1 + "\nd2 is " + d2); // here is the output

}

public static void method(Date d1, Date d2) {

d2.setYear (100);

d1 = d2; // I am confuse by this line

}

}


Regards,
Indravadan Patel
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would love to reply to your post, but it isn't in the right forum, it has nothing to do with servlets CarefullyChooseOneForum.
Someone of the moderators will move it to its right place.
I'll post my reply there

Hope this helps
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Amit said.

Also, it is a little absurd to post code to a forum, asking what the output would be. Why not compile and run it yourself?

Tell us what the output is.
Then, if there is something you don't understand, ask a more specific question.

Moving to Java In General (Beginner)
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please spend you bit time here.Java is pass by Value.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic