File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes What is the output and Why Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the output and Why" Watch "What is the output and Why" New topic

What is the output and Why

Indravadan T Patel

Joined: Sep 09, 2007
Posts: 29
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



Indravadan Patel
Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2851

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

|Asking Good Questions|
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

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)

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Please spend you bit time here.Java is pass by Value.
I agree. Here's the link:
subject: What is the output and Why
It's not a secret anymore!