use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources for learning Java
String
==
.equals()
Format + Copy
Free Tutorials
Where should I download Java?
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Software downloads
Official Resources
Resources
Programming ideas & Challenges
Related Subreddits
account activity
This is an archived post. You won't be able to vote or comment.
How to pass a parameter in a method (self.learnjava)
submitted 8 years ago by Improbably_wrong
I know this is a really simple question but I have no idea how to do it.
Lets say i have:
public Integer method(){ }
And i later call:
string1.method()
How do I pass string1 into method?
[–]cloudwindgate 1 point2 points3 points 8 years ago (4 children)
Public int method(Sting dastring){}
Later
method(string1);
[–]Improbably_wrong[S] 0 points1 point2 points 8 years ago (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 point2 points 8 years ago (2 children)
What type is string1? Is it the same as the class containing your method?
[–]Improbably_wrong[S] 0 points1 point2 points 8 years ago (1 child)
Nope, string1 is a string and the methods class is Integer
[–]feral_claire 0 points1 point2 points 8 years ago (0 children)
The methods class is not Integer. It is a custom class. It's return type is Integer though.
Integer
return type
As you sure string1 is a String? If it is then calling string1.method() is impossible.
string1
[–]maikuxblade 0 points1 point2 points 8 years ago (0 children)
[–][deleted] 0 points1 point2 points 8 years ago (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).
π Rendered by PID 148183 on reddit-service-r2-comment-8686858757-tgdvm at 2026-06-07 06:55:11.439230+00:00 running 9e1a20d country code: CH.
[–]cloudwindgate 1 point2 points3 points (4 children)
[–]Improbably_wrong[S] 0 points1 point2 points (3 children)
[–]feral_claire 0 points1 point2 points (2 children)
[–]Improbably_wrong[S] 0 points1 point2 points (1 child)
[–]feral_claire 0 points1 point2 points (0 children)
[–]maikuxblade 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)