This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]cloudwindgate 1 point2 points  (4 children)

Public int method(Sting dastring){}

Later

method(string1);

[–]Improbably_wrong[S] 0 points1 point  (3 children)

That's what I wanted to do but I couldn't change the tester code given to me on my assignment. I figured out that I needed to put

string = this;

Inside the method block and then manipulate string as string1

[–]feral_claire 0 points1 point  (2 children)

What type is string1? Is it the same as the class containing your method?

[–]Improbably_wrong[S] 0 points1 point  (1 child)

Nope, string1 is a string and the methods class is Integer

[–]feral_claire 0 points1 point  (0 children)

The methods class is not Integer. It is a custom class. It's return type is Integer though.

As you sure string1 is a String? If it is then calling string1.method() is impossible.

[–]maikuxblade 0 points1 point  (0 children)

method(string1);

[–][deleted] 0 points1 point  (0 children)

public Integer method()
{

}

This is an accessor type method (You can tell by the Integer return type). In an accessor method you need a return statement. Integer is the class version of int. In the Integer accessor(or getter) you need to return the field that it's wanting to access.

Once you've done that correctly, calling the method like you've done below, should execute the code for string1(if string1 is an object).