Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

Please help me to solve this java code....:-) find the errors in this code shown in the following comment.....

OpenStudy (anonymous):

import java.util.Calendar; public class Calendar1{{ public static void main(String []args){ Calendar now = Calendar.getInstance(); System.out.println("Current date :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); now.add(Calendar.DATE,1); System.out.println("Date after one day :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); now = Calendar.getInstance(); now.add(Calendar.DATE, -10); System.out.println("Date after one day :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); } }

OpenStudy (anonymous):

What is the output of the program?

OpenStudy (anonymous):

output is: current date in our system Date after one day i.e., tomorrows date Date before ten days ......@jtryon

OpenStudy (anonymous):

import java.util.Calendar; public class Calendar1{ public static void main(String []args){ Calendar now = Calendar.getInstance(); System.out.println("Current date :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); now.add(Calendar.DATE,1); System.out.println("Date after one day :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); now = Calendar.getInstance(); now.add(Calendar.DATE, -10); System.out.println("Date before ten days :" + (now.get(Calendar.MONTH)+1)+"-"+(now.get(Calendar.DATE))+"-"+(now.get(Calendar.YEAR))); } } Fixed the code, you had an extra bracket before the start of the main class, removed that and it compiles fine and outputs, also fixed the last text of the third string. Cheers! :)

OpenStudy (anonymous):

Thank you.... @Oinea

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!