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 Numbercheck.java. 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. http://www.jcreator.com/download.htm
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.
/**
* @(#)Numbercheck.java
*
*
* @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
}
System.out.println("Range:"+(a-b));
//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
}
}