Java, defining a method -
i'm new programming....not sure how add / define methods lower half of program work.
import static java.lang.system.out; import java.text.*; import java.util.*; import java.lang.*; public class dates { // --- add methods here make program work --- // // attempted solution nameformat method!!!!!!
//keep getting "cannot find symbol - variable nameformat //or cannot convert string int error if give return value //have scoured internet examples , can't figure out.
public static int nameformat(int year, int month, int day) { simpledateformat nameformat = new simpledateformat("yyyy, mm, dd"); date date = nameformat.parse("2014, 10, 4"); simpledateformat sdfdestination = new simpledateformat("mmmmm dd, yyyy"); return nameformat < not sure put here; } public static void printdate(int year, int month, int day) { out.println(nameformat(year, month, day)); out.println(slashformat(year, month, day)); out.println(dashformat(year, month, day)); out.println(); } public static void main(string[] args) { printdate(2014, 10, 4); printdate(2015, 1, 1); printdate(2013, 12, 31); } }
look here understanding how method works: http://mathbits.com/mathbits/java/methods/lesson1.htm
generally, how method defined:
public static int functionname(int a, int b ...) { // put want method do. return (something); }
Comments
Post a Comment