r/learnjava • • Dec 08 '17

Calling methods of a different class query

Hi guys.

Say I have a method in class A.

I then wish to call the method from class A in public static void main(String[] args).

How would I do so?

0 Upvotes

22 comments sorted by

6

u/[deleted] Dec 08 '17

Since this is a homework assignment, and, as other users have stated, you are needlessly flooding the subreddit, please read your coursebook and finish the tutorials in the sidebar.

It is simply impossible to not grasp the concept of methods, scopes, getters/setters and private/public fields after finishing the MOOC.

Please don't be ignorant.

1

u/[deleted] Dec 08 '17

Needlessly?

That is your opinion.....

And as I have said, there has been offensive language which is against the subreddit.

Please don't be so judgemental.

4

u/[deleted] Dec 08 '17

That's lovely and all, but you're missing the point that it is simply impossible not to grasp these basic concepts if you've actually read your books and finished the tutorials. That's just plain ignorant, and blatantly wasting other people's time.

Now, please stop playing the victim and do some actual studying instead of complaining about inefficient faculties and foul language. Worse than foul language is wasting our time and your own.

1

u/[deleted] Dec 08 '17 edited Dec 08 '17

That's lovely and all, but rules ARE rules, and your'e missing the point that I didn't play the victim, I merely pointed out a simple fact. Dare I say...a basic concept impossible to ignore?

Now, please stop pompously scolding me and forgetting your place. You ARE NOT a moderator, or in charge of the site. I have done actual studying.

4

u/[deleted] Dec 08 '17

Naturally, rules are rules. But that does not excuse your ignorance. Furthermore, my place is as a member of society, which gives me the right to call out any bullshit wothin the boundaries of the law. Seems to me I'm doing a fair job at thay, even within Reddit rules.

The fact that you do not understand the basic concepts is a testament of your lack of studying and finishing tutorials. You deliver the proof yourself by posting these basic questions. More shocking is attempting to claim that yoi have studied. Which is fine, just not true.

Now, I could go on and point out your ignorance and negligence, but what good would that do? Ignorance cannot be cured. You will simply feel you are right and we are wrong.

1

u/[deleted] Dec 08 '17

wothin =="Within"

thay=="that"

Ignorance: "lack of knowledge or information".

Ironic that you seem unable to spell....you seem such an expert on the matter of ignorance, exuding such volumes of it yourself.

8

u/[deleted] Dec 08 '17

Ignorant has a certain nuance that implies not only a lack of knowledge, but also the unwillingness to learn. Now, a personal attack on my spelling is perfectly reasonable from the point of view of a wounded ego trying to safe face, so I'll humour you and apologise for making such a grave mistake.

Now, back to actual studying you go. Godspeed

3

u/empire539 Dec 08 '17

If the method is non-static, then you probably will need to instantiate an A object first, e.g.

A a = new A();
a.myMethod();

Otherwise, if the method is static, you should be able to call it directly on A: A.myStaticMethod().

1

u/koproller Dec 08 '17

Can't you also make singleton?

4

u/that_one_dev Dec 09 '17

Do you mean something like this?

Singleton.getInstance().someMethod()

That would be fine but I don't think someone who doesn't understand objects and methods should be worried about a singleton just yet

-1

u/[deleted] Dec 08 '17

Oh, yeah forgot about that....thanks! :)

4

u/that_one_dev Dec 09 '17 edited Dec 09 '17

I don't think you know what a singleton means if you don't know how to call a method

6

u/throwaway_for_cause Dec 08 '17 edited Dec 08 '17

Have you ever considered doing a tutorial instead of flooding (6 posts in the last 24 hours) the subreddit?

The sidebar here has some of the best Java tutorials in existence in the Free Tutorials section.

You will need a lot more than a couple reddit posts can fill. Take a proper tutorial and learn the correct way.

The MOOC Object Oriented Programming with Java (sidebar) will teach you what you are lacking.

-8

u/[deleted] Dec 08 '17

[removed] — view removed comment

7

u/override_acid Dec 08 '17

No need to be a dick about a valid suggestion.

You have huge gaps in your knowledge that you need filled, so suggesting a tutorial is the appropriate way to go.

This is not the first time you blow up to a perfectly valid comment. You should reconsider your attitude.

You are flooding the subreddit. There is no discussion about that. Flooding is against the Reddit Terms of Service and against the reddit rules about spamming, even if your questions are pertaining to Java and valid.

-4

u/[deleted] Dec 08 '17

You condemn me for my attitude, and yet choose to use curse words? You do realise that also is a clear violation of the Reddit Terms of Service, specifically concerning:

Unwelcome content as well Do not threaten, harass, or bully, in addition to vulgar, harrassing and or offensive.

Perhaps you should follow the rules yourself, before so prissily demanding that of others.

5

u/override_acid Dec 08 '17

Telling you that you behave like an asshole and a dick is neither threatening, nor harassing, nor bullying. It's simply calling you out on your inappropriate behavior that you continue to display.

This has nothing to do with the reddit TOS because I was not calling you this, I was stating that you behave like one - which is a completely different context and meaning.

6

u/[deleted] Dec 08 '17

These are the people that are going to be taking time out of their day to help explain something to you. I would suggest being more respectful rather than saying the equivalent of "you aren't a mod, pound sand".

3

u/desrtfx Dec 09 '17

Ahem... https://i.imgur.com/P7qEUPW.png

/u/throwaway_for_cause is a moderator and even if he weren't, he could still state his opinion without you having even the slightest right to go against him.

You are again misbehaving and have been in the entire thread. If you don't learn to properly behave yourself and stop your constant threatening and reporting, you will face consequences.

Even your mail to the moderators was inappropriate. Moderators have full rights how to run their communities and full responsibility. They can do in their communities basically what they want.

Your behavior is unacceptable, and you have been called out by members of the community who are here longer than you are. It is their full right to call you out when you're misbehaving. Moderators or not. Instead of going against those people, you should accept what they are telling you and change your attitude.

A single more step out of line will get you permanently banned.

You don't need to report this as offensive, abusive, or threatening. I'm just stating facts and warning you.

-4

u/[deleted] Dec 08 '17

[removed] — view removed comment

5

u/override_acid Dec 08 '17

Have you considered I have DONE a tutorial, and yet still struggled to grapple with the concepts of it?

Well, even then, the suggestion is perfectly valid and doesn't give you a permit to behave like an asshole. If a single tutorial is not sufficient, do another one, and another, and another until you understand it.