Forum
Java Problem
Created 1st November 2010 @ 05:47
Add A Reply Pages: 1
So I’ve been trying to learn Java and I have come across a problem.
import java.util.*;
class ClockTalk {
public static void main(String[] arguments) {
// get current time and date
Calender now = Calender.getInstance();
int hour = now.get(Calender.HOUR_OF_DAY);
int minute = now.get(Calender.MINUTE);
int month = now.get(Calender.MONTH) + 1;
int day = now.get(Calender.DAY_OF_MONTH);
int year = now.get(Calender.YEAR);
// display greeting
if (hour < 12)
System.out.println("Good morning. n");
else if (hour 12) ? (hour - 12) : hour );
System.out.print(" o'clock on ");
//display the name of the month
switch (month) {
case 1:
System.out.print("January");
break;
case 2:
System.out.print("February");
break;
case 3:
System.out.print("March");
break;
case 4:
System.out.print("April");
break;
case 5:
System.out.print("May");
break;
case 6:
System.out.print("June");
break;
case 7:
System.out.print("July");
break;
case 8:
System.out.print("August");
break;
case 9:
System.out.print("September");
break;
case 10:
System.out.print("October");
break;
case 11:
System.out.print("November");
break;
case 12:
System.out.print("December");
}
// display the date and year
System.out.println(" " + day + ", " + year + ".");
}
}
When trying to compile this code throught “javac ClassTalk.java” it comes up with this problem:
“ClockTalk.java:6: cannot find symbol
symbol : class Calender
location : class ClockTalk
Calender now = Calender.getinstance();
^”
That and several other problems with the Calender class. My CLASSPATH enviromental variable is set to .;C:Program FilesJavajdk1.6.0_22libtools.jar which should be correct afaik. I can’t see what the problem is so any help would be apreciated :)
Last edited by jgmaster,
You’re importing the utils, but you’ve spelt calendAr wrong. It shouldn’t be calendEr.
Quoted from octochris
You’re importing the utils, but you’ve spelt calendAr wrong. It shouldn’t be calendEr.
06:20 – [LLC] DeathbyJG: if i do import java.util.Calender;
06:20 – [LLC] DeathbyJG: it doesnt like that either
06:20 – [FB] Chris the FABULOUS Fatman: oh, well if it’s from the utils then you’re spelling it wrong
06:20 – [FB] Chris the FABULOUS Fatman: it’s spelt calendAr not calendEr
06:21 – [LLC] DeathbyJG: did i write calendar?
06:21 – [FB] Chris the FABULOUS Fatman: all over your code you have written “calender”
06:21 – [FB] Chris the FABULOUS Fatman: where it should be “calendar”
06:21 – [FB] Chris the FABULOUS Fatman: i assumed you named it that to differentiate it
06:21 – [LLC] DeathbyJG: if this is a typo i will scream
06:21 – [FB] Chris the FABULOUS Fatman: but i guess maybe you just made a spelling mistake
06:22 – [LLC] DeathbyJG: :/
06:22 – [LLC] DeathbyJG: i need to learn english
:3 Oh and can be locked.
Last edited by jgmaster,
//display the name of the month
switch (month) {
case 1:
System.out.print(“January”);
break;
case 2:
System.out.print(“February”);
break;
case 3:
System.out.print(“March”);
break;
case 4:
System.out.print(“April”);
break;
case 5:
System.out.print(“May”);
break;
case 6:
System.out.print(“June”);
break;
case 7:
System.out.print(“July”);
break;
case 8:
System.out.print(“August”);
break;
case 9:
System.out.print(“September”);
break;
case 10:
System.out.print(“October”);
break;
case 11:
System.out.print(“November”);
break;
case 12:
System.out.print(“December”);
}
sweet mother of
Quoted from d1ck j0nes
[…]
sweet mother of
some of the worst code i’ve ever seen (but it is java after all), nevertheless the solution was equally funny
Last edited by octochris,
Add A Reply Pages: 1