Results 1 to 3 of 3
  1. #1
    Fuzztional is offline Member
    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0

    Default DAY_OF_YEAR problem returning the method

    Here's the code.

    import java.util.GregorianCalendar;
    import java.util.Calendar;
    import java.text.SimpleDateFormat;

    public class Dt3 {
    public static int nrOfDays(String year) {

    GregorianCalendar c = new GregorianCalendar();
    int dayOfYear = c.get(Calendar.DAY_OF_YEAR);

    return dayOfYear;
    }
    public static void main(String [] args) {

    System.out.println(nrOfDays);

    }
    }



    Problem is i can't seem to get it to printout the nrofday, if i remove the println it dosen't give me any errors which. The task is to return the day of year not to print it, but i wanted to make sure i got this one right.

    If anyone can explain to me why this isn't working ill be grateful.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: DAY_OF_YEAR problem returning the method

    Your method nrOfDays doesn't need the year parameter, it's never used. When calling a method, the syntax is methodName(parameters)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    ongsanb7 is offline Member
    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0

    Default Re: DAY_OF_YEAR problem returning the method


Similar Threads

  1. Problem returning in a method
    By therealvasile in forum New To Java
    Replies: 14
    Last Post: 07-12-2013, 08:43 AM
  2. Calendar DAY_OF_YEAR problem in 1.6?
    By du-it in forum Advanced Java
    Replies: 3
    Last Post: 03-05-2012, 10:57 AM
  3. Replies: 1
    Last Post: 12-15-2011, 04:02 AM
  4. Replies: 4
    Last Post: 03-29-2011, 07:34 AM
  5. My method keeps returning 0
    By ToolJob in forum New To Java
    Replies: 11
    Last Post: 03-27-2011, 05:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •