Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

learning java

Thread view: 
Jacky Luk - 02 Oct 2006 09:55 GMT
import java.awt.Graphics;

public class test1 extends java.applet.Applet {
    //@Override
 private String str;
 private String str2;
 public test1()
 {
  str = "come on";
  str2 = " my friend";
 }
 public void init()
 {
  str.concat(str2);
 }

    public void paint(Graphics g) {

        g.drawString("Hello from java!", 60, 30);
        g.drawString(str, 100, 100);
    }
}

How come str should be "come on my friend" instead of just "come on"? but
the applet just displayed "come on" without "my friend", so what happened?
Thanks
Jack
Andrew Thompson - 02 Oct 2006 10:11 GMT
....
>   public void init()
>   {
>    str.concat(str2);

This is 'throwing away the result', try instead..
  str = str.concat(str2);
...

Andrew T.
Jacky Luk - 02 Oct 2006 10:20 GMT
perfect fit! thanks
Jack

"Andrew Thompson" <andrewthommo@gmail.com>
???????:1159780274.283238.320060@i42g2000cwa.googlegroups.com...
> ....
>>   public void init()
[quoted text clipped - 6 lines]
>
> Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.