Thread View: aus.computers.java
2 messages
2 total messages
Started by Qinhe Zheng
Fri, 04 Jun 1999 00:00
Help!!! What is wrong with my code?
Author: Qinhe Zheng
Date: Fri, 04 Jun 1999 00:00
Date: Fri, 04 Jun 1999 00:00
24 lines
1196 bytes
1196 bytes
hey guys, i am a java applet beginner. please tell me what is wrong with my
code.
i am suppose to write an applet that displays the current time when it
started. i want to
get it right so desperately. if you know whats wrong. pleassssee email me at
Qin@mingspring.com thanks in advance.
import java.awt.*;
import java.applet.Applet;
import java.util.Date;
public class Clock extends Applet
{
public void paint( Date g)
{
Date myTime = new Date();
int myHour = myTime.getHours();
int myMinute = myTime.getMinutes();
int mySecond = myTime.getSeconds();
g.drawString(myHour + myMinute);
}
}
Re: Help!!! What is wrong with my code?
Author: Jason Zaugg
Date: Sat, 05 Jun 1999 00:00
Date: Sat, 05 Jun 1999 00:00
14 lines
921 bytes
921 bytes
<snip> >if you know whats wrong. pleassssee email me at >Qin@mingspring.com thanks in advance. <snip> > g.drawString(myHour + myMinute); g.drawString(myHour + ":" myMinute); will stop Java from adding the two ints. The '+' operator is overloaded -- that is it has different meanings depending on context. Usually it adds numbers, but for convenience, it also concatenates Strings (which would look real ugly otherwise")
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads