Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Problem with sending a GregorianCalender HELP

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with sending a GregorianCalender HELP

    right i am studying a degree course and i am having trouble with this line of code-
    	public static void main(String [] args)
    	{
    		Item rent1 = new Item(1000001, "Last Samurai", "Action", 2004, "15", new GregorianCalendar(2010,3,15 ) );
    		rent1.returnItem(Date_Last_Returned)
    		rent1.display();
     
    	}
    }
    this is my main application and below is the code that will not work correctly-

    rent1.returnItem(Date_Last_Returned)

    i am sending this back to this item class-
    import java.util.GregorianCalendar;
     
    public class Item 
    {
    	private int identifier;
    	private String title;
    	private String genre;
    	private int year_released;
    	private String classification;
    	private GregorianCalendar Date_Last_Returned;
    	private boolean available;
     
    	public Item(int identifier, String title, String genre, int year_released, String classification, GregorianCalendar Date_Last_Returned)
    	{
    	this.identifier=identifier;
    	this.title=title;
    	this.genre=genre;
    	this.year_released=year_released;
    	this.classification=classification;
    	this.Date_Last_Returned=Date_Last_Returned;
    	}
    	public GregorianCalendar getDate()
    	{
    		return Date_Last_Returned;
     
    	}
    	public void display()
    	{
    		System.out.println("Here is the identifier- "+identifier);
    		System.out.println("Here is the Date Last Returned- "+Date_Last_Returned.getTime());
    	}
    	public GregorianCalendar returnItem(GregorianCalendar Date_Last_Returned) 
    	{
    		Date_Last_Returned.set(2010, 3,16);
    		available=true;
    		return Date_Last_Returned;
     
    	}
     
    }
    this line of code is frying my head and i can not see or figure out why it is not working for me, can anyone help please???


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Problem with sending a GregorianCalender HELP

    What do you mean by it isn't working? What is happening that shouldn't?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Problem with sending a GregorianCalender HELP

    rent1.returnItem(Date_Last_Returned);
    is causing an error because Date_Last_Returned cannot be resolved to a variable

    You are calling the returnItem(); method with Date_Last_Returned as an argument but Date_Last_Returned is not a variable declared in this class.

    The method:

    	public GregorianCalendar returnItem(GregorianCalendar Date_Last_Returned) 
    	{
    		Date_Last_Returned.set(2010, 3,16);
    		available=true;
    		return Date_Last_Returned;
     
    	}

    Requires a GregorianCalendar argument.

    To demonstrate, try adding this to your main method:

    		GregorianCalendar Date_Last_Returned = new GregorianCalendar(2010, 3,16);		
    		rent1.returnItem(Date_Last_Returned);	
    		rent1.display();
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Sending SMS in java
    By pipi in forum What's Wrong With My Code?
    Replies: 12
    Last Post: January 26th, 2011, 08:10 PM
  2. Sending object through socket
    By Alexandrinne in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 16th, 2010, 02:18 AM
  3. Problem sending POST request with Java..
    By lost in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 09:16 PM
  4. Sending XML over HTTP to Another Application
    By darasgar in forum Java Servlet
    Replies: 2
    Last Post: July 14th, 2010, 01:56 PM
  5. Java problem -- sending email via JSP page
    By java_beginner in forum Java Theory & Questions
    Replies: 2
    Last Post: June 28th, 2010, 02:35 AM