• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the output and Why

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please spend you bit time here.Java is pass by Value.
reply
    Bookmark Topic Watch Topic
  • New Topic