Number check

By ^Neptune on Nov 20, 2008


My first Java code!

I was getting a bit sick of mIRC seeing as it didn't have any practical uses in life. Although, this really doesn't serve any practical purpose either but I reckon it's a great start for only starting an hour ago. :P

I mainly posted it up here so that people can get an insight into Java. I have also added tons of comments so a user can hopefully follow the code and understand what it is doing. It's very basic, and something that might seem pointless, but it could be good for people just starting Java, ya never know.

The script will check by the two variables (you can change the values) and return information depending on which is bigger.

---How to use---
You'll need to open your Java compiler and paste the code in.

I CANNOT STRESS IT ENOUGH THAT YOU MUST KNOW WHAT YOU ARE DOING LOADING THIS. The filename MUST be Otherwise, if it isn't, it will not work. And yes, it IS CASE SENSITIVE.

If you do not have a compiler and want to try this, I suggest getting JCreator. It's totally free and easy to use.

If anyone knows how to do the $? equivalent in Java, please let me know! I want to make the user able to input the variable values.

 * @(#)
 * @author Neptune
 * @version 1.00 2008/11/20

public class Numbercheck {

    //Defining the class (must be exactly the same as the filename (case-sensitive, too)

    public static void main(String[] args) {

        //Declares it accessible from outside the class

        int a = 10, b = 5;

        //Sets the variables
        //a is declared as 10
        //b is declared as 5
        //You can change the variable values to whatever you want to test the script better

            System.out.println("First number:"+a);
            System.out.println("Second number:"+b);

            //These two lines print out the first and second number
            //The + sign is used to combine strings

        if (a > b) {

            //Check if a is bigger than b

            System.out.println("Biggest number:"+a);

            //Print out that a is bigger than b

        else {

            //This basically means if the first statement is false, do whatever else I put under the else
            //In this case, it would mean that b is bigger than a

            System.out.println("Biggest number:"+b);

            //Print out that b is bigger than a


        //Print out the difference between the biggest and smallest number
        //You can simply enclose an equation in () brackets to make it calculate itself
        //This line will be printed out no matter what, as it is outside the if and else brackets



Sign in to comment.
Joshuaxiong1   -  Nov 16, 2009

I wish I can play like this like other Java in here.

guest598594   -  Apr 04, 2009
^Neptune   -  Nov 21, 2008

What's with the 1.4?

I know it's not that amazing and all but it's not either ripped or incomplete. =/

Firstmate   -  Nov 20, 2008

Edit: bad link

^Neptune   -  Nov 20, 2008

That's what I said in the intro, lol

Still trying to figure out how you can do it.

guest598594   -  Nov 20, 2008

You should have the user enter two numbers

^Neptune   -  Nov 20, 2008

Screenshot has been added.

Considering I have only been learning for an hour, I think I'm doing pretty well. =]

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.