For Programmers: Free Programming Magazines  


Home > Archive > Java Help > August 2005 > writing a method..









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author writing a method..
Frances

2005-08-24, 7:00 pm

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.

2005-08-24, 7:00 pm

Frances wrote:
> 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..


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.
Monique Y. Mudama

2005-08-24, 7:00 pm

On 2005-08-24, Frances penned:
> 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


Is the method inside a class?

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

--
monique

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

2005-08-24, 7:00 pm

T. wrote:
> Frances wrote:
>
>
>
> class MyClass{
>
> String answer = "Hello World";
> return answer;
> }
> }
>
> 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...OO/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..




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com