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 / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

writing a method..

Thread view: 
Frances - 24 Aug 2005 15:52 GMT
I have read about methods until I'm blue in the face..

yet every time I try to write my own method from scratch I get "illegal
start of expression" error no matter how I declare it..

public String myMehtod() {
private String myMethod() {
String myMethod () {  // on this one says I need ';' at
                    //  end of this line....????

this is a method that simply processes a string...  (I have 'return
<StringVar>' at the end..

this is very frustrating.. would appreciate some help, pls..  thank you..

Frances
T. - 24 Aug 2005 16:32 GMT
> I have read about methods until I'm blue in the face..
>
[quoted text clipped - 10 lines]
>
> this is very frustrating.. would appreciate some help, pls..  thank you..

class MyClass{
 public String myMethod(){
    String answer = "Hello World";
    return answer;
 }
}

Is this wat you mean?
Maybe you can start with a java tutorial like the ones on
http://java.sun.com/docs/books/tutorial/index.html

Just follow the creation of a program step by step...

T.
Frances - 24 Aug 2005 16:52 GMT
>>I have read about methods until I'm blue in the face..
>>
[quoted text clipped - 19 lines]
>
> Is this wat you mean?

yes, this is what I mean.. thank you..  I HAVE read up on methods, among
others (MANY others...)
http://scv.bu.edu/Doc/Java/tutorial/java/javaOO/methods.html

this is for an applet..  I had this method inside init() method, I took
it out of there, now it's just inside applet class...  I declare class,
I declare vars, I declare the method..   this is a method that will do
nothing more than process an e-mail address to convert it to something
else.. I need to pass a string to the method.. but string I need to pass
is a var, not a literal.. so can I do..

  public String myMethod(String sUid){

then in method call pass var that will be drawn from a getParameter()
method (pulling param from html that calls applet..):

       sUid = getParameter("uid");

this var I need to pass to method and process...

thank you very much..
Monique Y. Mudama - 24 Aug 2005 16:38 GMT
> I have read about methods until I'm blue in the face..
>
[quoted text clipped - 12 lines]
>
> Frances

Is the method inside a class?

public class Foo
{
    public String myMethod()
    {
        return "Foo";
    }
}

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



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.