Jump to content

Recommended Posts

Posted (edited)
AuvL2kM.png
 
 
 
These tutorials will introduce you to Java programming Language. You'll compile and run your very own Java application, using Sun's JDK. It's extremely easy to learn java programming skills, and in these parts, you'll learn how to write, compile, and run Java applications. Before you can develop corejava applications, you'll need to download the Java Development Kit (JDK).  http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
 
 
Java If-Else Statement
 
The if-else class of statements should have the following form:
 
if (condition) {
statements;
}


if (condition) {
statements;
} else {
statements;
}


if (condition) {
statements;
} else if (condition) {
statements;
} else {
statements;
}
 
All programming languages have some form of an if statement that allows you to test conditions. All arrays have lengths and we can access that length by referencing the variable arrayname.length.  We test the length of the args array as follows:
 
Source Code
 
// This is the Hello program in Java
class Hello {


    public static void main (String args[]) {
    
      /* Now let's say hello */
      System.out.print("Hello ");
      if (args.length > 0) {
        System.out.println(args[0]);
      }
  }


}
Compile and run this program and toss different inputs at it. You should note that there's no longer an ArrayIndexOutOfBoundsException if you don't give it any command line arguments at all.
What we did was wrap the System.out.println(args[0]) statement in a conditional test, if (args.length > 0) { }. The code inside the braces, System.out.println(args[0]), now gets executed if and only if the length of the args array is greater than zero. In Java numerical greater than and lesser than tests are done with the > and < characters respectively. We can test for a number being less than or equal to and greater than or equal to with <= and >= respectively.
 
Testing for equality is a little trickier. We would expect to test if two numbers were equal by using the = sign. However we've already used the = sign to set the value of a variable. Therefore we need a new symbol to test for equality. Java borrows C's double equals sign, ==, to test for equality. Lets look at an example when there are more then 1 statement in a branch and how braces are used indefinitely.
 
Source Code
 
import java.io.*;
class NumberTest
{
public static void main (String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) );


String inS;
int num;


System.out.println("Enter an integer number");
inS = stdin.readLine();
num = Integer.parseInt( inS ); // convert inS to int using wrapper classes


if ( num < 0 )  // true-branch
{
     System.out.println("The number " + num + " is negative");
  System.out.println("negative number are less than zero"); 
}
else   // false-branch
{
  System.out.println("The number " + num + " is positive");
  System.out.print ("positive numbers are greater ");
  System.out.println("or equal to zero ");
}
System.out.println("End of program"); // always executed
}
}
        
All conditional statements in Java require boolean values, and that's what the ==, <, >, <=, and >= operators all return. A boolean is a value that is either true or false. Unlike in C booleans are not the same as ints, and ints and booleans cannot be cast back and forth. If you need to set a boolean variable in a Java program, you have to use the constants true and false. false is not 0 and true is not non-zero as in C. Boolean values are no more integers than are strings.
 
Else
 
Lets look at some examples of if-else:
 
//Example 1
if(a ==  {
c++; 
}
if(a !=  {
c--;
}


//Example 2
if(a ==  {
c++; 
}
else {
c--;
}
 
We could add an else statement like so:
 
Source Code
 
// This is the Hello program in Java
class Hello {


    public static void main (String args[]) {
    
      /* Now let's say hello */
      System.out.print("Hello ");
      if (args.length > 0) {
        System.out.println(args[0]);
      }
      else {
        System.out.println("whoever you are");
      }
  }


}
 
Source Code
 
public class divisor
{
public static void main(String[] args)
         int a = 10;
         int b = 2;
         if ( a % b == 0 )
         {
               System.out.println(a + " is divisible by "+ ;
         }
         else
         {
               System.out.println(a + " is not divisible by " + ;
         }
}
Now that Hello at least doesn't crash with an ArrayIndexOutOfBoundsException we're still not done. java Hello works and Java Hello Rusty works, but if we type java Hello Elliotte Rusty Harold, Java still only prints Hello Elliotte. Let's fix that.
We're not just limited to two cases though. We can combine an else and an if to make an else if and use this to test a whole range of mutually exclusive possibilities. 
 
Lets look at some examples of if-else-if:
 
//Example 1
if(color == BLUE)) {
System.out.println("The color is blue.");
}
else if(color == GREEN) {
System.out.println("The color is green.");
}


//Example 2
if(employee.isManager()) {
System.out.println("Is a Manager");
}
else if(employee.isVicePresident()) {
System.out.println("Is a Vice-President");
}
else {
System.out.println("Is a Worker");
}
 
Source Code
// This is the Hello program in Java
class Hello {


    public static void main (String args[]) {
    
      /* Now let's say hello */
      System.out.print("Hello ");
      if (args.length == 0) {
        System.out.print("whoever you are");
      }
      else if (args.length == 1) {
        System.out.println(args[0]);
      }
      else if (args.length == 2) {
        System.out.print(args[0]);
        System.out.print(" ");
        System.out.print(args[1]);
      }      
      else if (args.length == 3) {
        System.out.print(args[0]);
        System.out.print(" ");
        System.out.print(args[1]);
        System.out.print(" ");
        System.out.print(args[2]);
      }      
        System.out.println();
  }

}

I wish you find this guide helpful, Thanks!

 

Edited by Sawadee
  • Upvote 1
Posted

I think it would be more fun to learn if examples would be related to L2, you could find some codes that are similar in most of h5 and IL packs and show how they can be modified. Top of CharacterCreate packet is similar in most of the packs, you could make for example:

if(_sex == 1) {
    _name = "F" + _name;
}
else
{
    _name = "M" + _name;
}

Useless code, but it can be easily tested in game and it have significant impact - not like console println.

 

 

You could also mention that { } are not required. Also variable = condition ? trueStatement : falseStatement; would be nice to be put here.

 

Good work :)

Posted (edited)

I think many people wouldn't read it because the examples isn't for L2.

I'm not saying it's pointless or something.. I like guides like this one..

 

But they would find it difficult because they want easy steps. Maybe not easy steps, but easily and understanding steps.

 

Good work...

Thanks!

Edited by 'Baggos'
Posted

I think it would be more fun to learn if examples would be related to L2, you could find some codes that are similar in most of h5 and IL packs and show how they can be modified. Top of CharacterCreate packet is similar in most of the packs, you could make for example:

if(_sex == 1) {
    _name = "F" + _name;
}
else
{
    _name = "M" + _name;
}

Useless code, but it can be easily tested in game and it have significant impact - not like console println.

 

 

You could also mention that { } are not required. Also variable = condition ? trueStatement : falseStatement; would be nice to be put here.

 

Good work :)

 

 

I think many people wouldn't read it because the examples isn't for L2.

I'm not saying it's pointless or something.. I like guides like this one..

 

But they would find it difficult because they want easy steps. Maybe not easy steps, but easily and understanding steps.

 

Good work...

Thanks!

 

Thank you guys, I know you are right this guide is not related for Lineage2 but i think they must know some basic stuff before they start to code for L2 :)

Posted

That's what they say, remake it so they can learn the basic stuff by doing small mods into l2.

 

I will start doin it in some minutes and share it back :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • https://vpslab.cloud/ Premium DDoS Protection now included with every server.
    • # Changelog - Public Updates   This changelog tracks user-facing updates and improvements to Top.MaxCheaters.com.   ---   ## [1.2.0] - 2026-01-XX   ### ⚡ Performance Improvements - **Faster Page Loads**: Implemented intelligent caching system that makes pages load significantly faster - **My Servers Page**: Now loads instantly when revisiting (no more loading delays) - **Main Page**: Server listings and filters now load faster on repeat visits - **Premium Ads**: Pricing information loads instantly - **Overall Performance**: Site now loads 60-80% faster with reduced server load   ### 🔄 Improvements - Pages now remember recent data, reducing wait times when navigating - Automatic cache refresh ensures you always see up-to-date information - Better user experience with instant page loads on repeat visits   ---   ## [1.1.1] - 2026-01-XX   ### 🐛 Bug Fixes - **VIP Server Filter**: Fixed "VIP L2 Servers" filter to correctly show all premium tier servers (VIP, Gold VIP, and Pinned) - **Ad Pricing Display**: Fixed ad pricing on Premium Ads page to automatically update when changed in admin panel   ### 🔄 Improvements - Ad pricing now syncs automatically across all pages - More accurate server filtering by tier   ---   ## [1.1.0] - 2026-01-XX   ### ✨ New Features - **Complete Chronicle List**: All chronicle options are now available in server forms and filters, including the latest Lineage 2 chronicles - **Improved Chronicle Display**: Server rows now show cleaner, shorter chronicle names for better readability   ### 🐛 Bug Fixes - **Chronicle Filter**: Fixed issue where "Infinite Odyssey" chronicle filter was not working correctly - **Missing Chronicles**: Fixed missing chronicle options in server creation and editing forms   ### 🔄 Improvements - Chronicle filters and dropdowns now stay in sync with the latest available chronicles - Better chronicle name formatting in server listings for improved visual clarity   ---   ## [1.0.0] - Initial Release   ### Features - 🎮 Server listings with multiple tiers (Normal, VIP, Gold VIP, Pinned) - 📊 Click tracking and server statistics - 🌍 Multi-language support (English, Spanish, Portuguese, Greek, Russian) - 💳 Payment system for premium server features - 🔐 Secure authentication system - 👑 Admin panel for server management - 📱 Fully responsive design for all devices - 🔍 Advanced filtering system (by chronicle, rate, server type, date) - 📅 Server opening date tracking - 🎯 Two viewing modes: By Date and By Votes (coming soon for all users)   ---   ## About This Changelog   This changelog focuses on updates that directly impact the user experience. Internal development changes and technical improvements are not included here.   For questions or feedback, please contact support.v
    • Now Acc Registration open. Create your account and get ready 🙂
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..