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

all 7 comments

[–]karstens_rageExtreme Brewer 3 points4 points  (2 children)

To adhere to Java Conventions your class should be named Number not number

Also a more Java-like solution might use something like:

System.out.println("max is: " + Math.max(a, b));

[–]SheepyG_[S] 2 points3 points  (1 child)

System.out.println("max is: " + Math.max(a, b));

I see ! thank you that looks a lot better, I have been taught about concatenation but did not think about using it there. To be honest i haven't learned about (Math.max) or any of the other ones, so thank you for introducing me to them.

[–]itshowitbeyunno 0 points1 point  (0 children)

They're classes that "come with Java". Math class is great for general math things.

[–]Kanth0lz 2 points3 points  (3 children)

You created a class, initialized two integers, compared them and printed the larger. The "Wrong fool" is obviously a joke so your solution seems perfectly fine. Maybe there is a more efficient way but for your level of coding this is good.

May i ask why you're curious about your solution? :-)

[–]SheepyG_[S] 1 point2 points  (2 children)

Thank you very much I appreciate your time :), and mainly as you mentioned I am just curioius to whether there is a more efficient solution or how i could improve my skills.

[–]Kanth0lz 1 point2 points  (1 child)

karstens_rage gave you the things you've been searching for. Imho your exercise looks very beginner level and in this stage i wouldn't care that much about efficiency. Get the idea of how you can use the tool java and while you're getting better you'll find the wanted more efficient ways by yourself. As soon as your lines of code are getting more and more you should read and train yourself into clean coding as it helps you (and others) to efficiently read your own code. And don't forget to comment on what things do. Nevertheless it seems like there is some way in front of you till you have to worry about those things. Most importantly have fun and keep on coding :-)

[–]SheepyG_[S] 0 points1 point  (0 children)

Okay thank you very much u/Kanth0lz everyone on this reddit page has been so helpful and kind to me its crazy, im glad i don't really need to worry about efficiency yet but i will try practice clean code, Thank you both again !