Jump to content

Recommended Posts

Posted

Hi guys

this guide is made for the little advanced user that have problem understanding the langauge

So you take the shared code here,compile it successfully but you don't know how it works?

Just a really brief look on the code don't expect anything good

 

So We start

 

We all see that in each java file there is always the word class

So what's the class anyway?

We define a class as an object and we can call it later by making a instance of it

So let's take an example from our life

now we  are going to implement things on it

for example our bank account got some money in it

 

- A class's name (the main class) has the same name of the file. All other classes (inner classes or nested classes) can be named whatever you want.

public class Account 
{
   int moneyAmount;
}

NOTE the code here isn't ready i just show some examples

so we made a field named moneyAmount type int

int means integer so it can be 1,2,3,4,5,6,8,9,0 although it stops somewhere and you must use for example long int

Now we are able to make functions(methods) that we can retrieve and take money back

pretty simple to make a method

public class Account
{
  int moneyAmount;

  public void withdraw()
  {
       ; //here we insert out statements what we want the method do
         // this can be done with multiple lines
  }     //close the brackets
} //close class brackets

So here we simple created a method

Now how do i call that method?

In your main just call it

Account.withdraw();

we inserted account to show that it is a method from account class

and called withdraw with ; in the end

 

Good till now

You can also pass arguments in the methods

for example

public void withdraw(int money) 
{
   ;
}

Now you can call it  like Account.withdraw(123);

 

Let's move to constructors

Constructors are used to create instances

Also constructors must have the same name with the class

let's make an example

public class Account 
{
  Account() {
                 ; //our code
                }
}

so you declared an constructor

now to build an account

from another class we call

Account acc;
acc = new Account();

Now we are going to talk about imports packages and the extend word

 

To use the code from other classes we have first to import them

how do i import classes?

 

at the top of your code you use

 

import packagename;

 

What's this pack anyway?

A package you can imagine is the folder that your java file exists

take a look

package com.server;

import com.server.Account;

Remeber package goes first the imports then classes

to access folders as you saw we use . not /

 

Let's take a look at the word extend that i am sure you have seen many times

By using extend in our class we automaticall get the code from the class we extended

let's take an example from l2j

public final class L2PcInstance extends L2PlayableInstance

ye you found it ^^

Something i want to point is

L2PcInstance is subclass of l2playable instance

and so it goes on when another class extends l2pcinstance  it becomes subclass of it and from l2playable

Also super class is the class that it is extened by another but it doesn't extend something else

 

Now let's talk about those public,private and all this crap

 

public,private,protected are  name access specifiers

we use them to change the accessibility of the class variable etc

so

 

public: can been seen from everywhere

 

protected: can be used only by itself and his subclasses

 

private: can been seen only by itself

 

public class Car
private class Car 

so goes on  same happens with fields (int,float,bool,etc)and our methods

 

Let's go to Modifiers

 

they are used after access specifiers

 

<acess specifiers> <modifiers> <type or class>  <variables>;

 

Modifiers are

 

final: it makes the variables constants

 

static: those make the vars/methods able to be called without having a instance made

 

abstract: it means that methods aren't going to have body in this class

 

There are others too though in l2j you won't need them

 

Operators:

What are those and why we need them

You already know the most

Let's Start

 


+
-
* (multiplies)
/ (divides)
%
^ powers

Bigger,less equal to


<= less or equal to
< less than
>= bigger or equal to
> bigger

Now something that ppl confuse


==   means equal to
!=    means not equal

And the last


&&  which means and
! which means NOT
|| which means OR

Be sure you are not using == with = because it's different

== means equal to and = is used to set values

for example

if (moneyAmmount == 100)
{ 
    System.out.println("You got 100 euros");
}

It's not the same with

if (moneyAmmount = 100)
{
     System.out.println("Wrong!you set money to 100");
}

In the second example we set money to 100 and it automaticall executes the statements because the condition it's true!

 

That's All hope you got learned something from here

feel free to ask me any question

 

Credits goes to me

 

 

 

Posted

Luke don't forget to explain them the obvious:

- A class's name (the main class) has the same name of the file. All other classes (inner classes or nested classes) can be named whatever you want.

Posted

Luke don't forget to explain them the obvious:

- A class's name (the main class) has the same name of the file. All other classes (inner classes or nested classes) can be named whatever you want.

thnx forgot to add that

Posted

Nice one, so many shares but non explanation. +1 karma.

 

You could improve the "extends" part a lil bit.

Posted

Nice one, so many shares but non explanation. +1 karma.

 

You could improve the "extends" part a lil bit.

 

It's for competition, you shouldn't give the karma.

He will either recieve it from the competition, or he won't recieve any karma at all.

 

Anyway I don't have problem for this xD

Posted

It's for competition, you shouldn't give the karma.

Yes, Reve. said that too :

 

4)You can't take karma for your guide if it doesn't win the competition.

 

So, i have to smite Maestro's karma , for now.

The guide is really good, so you have many chances of taking your karma point back. :)

Anyway, good luck and keep sharing!

Posted

Yes, Reve. said that too :

 

So, i have to smite Maestro's karma , for now.

The guide is really good, so you have many chances of taking your karma point back. :)

Anyway, good luck and keep sharing!

Np guys you know i am  really happy that ppl learn from here

Nice one, so many shares but non explanation. +1 karma.

 

You could improve the "extends" part a lil bit.

i will and i will update it till max characters xD

Posted

The extend class modifier is EXTREMELY simple. Picture this:

- You want to make a lot of cars, but all cars have common parts, like an engine, wheels,body,etc.

 So you make a new Class File named "CarClass" which contains basic information for all cars (engine,wheels,body,llala);

- When you make a new car Class File e.g. "SubaruImpreza" you extend the CarClass so that now, this file can access the CarClass's containers,methods, variables and classes, hence, avoiding unnecessary work. Its like a base template from which you start building other sites.

Posted

The extend class modifier is EXTREMELY simple. Image this:

- You want to make a lot of cars, but all cars have common parts, like an engine, wheels,body,etc.

  So you make a new Class File named "CarClass" which contains basic information for all cars (engine,wheels,body,llala);

- When you make a new car Class File e.g. "SubaruImpreza" you extend the CarClass so that now, this file can access the CarClass's containers,methods, variables and classes, hence, avoiding unnecessary work. Its like a base template from which you start building other sites.

shit i forgot overriding

w/e i gonna remake it tonight ;p

  • 6 months later...

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

    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server!  Create your free account here
    • I came out of my cave as I do once every 5 years. By now, I know nobody really cares about L2, but I still find it fun to experiment. Everything you see here will be free and open source. I have no interest in selling anything.   Long story short, I like to revisit Interlude and apply what I've learned to see how far I can push it. Here's Outerlude, a public fork of aCis for the modern age.   Video demo:   Work that has been done:   Redone the netcode from scratch to be async The NPC AI was completely redone based on Finite State Machines Moved to PostgreSQL and using some of its cool features Lots of config that should be hot reloadable has moved to the database OpenTelemetry instrumentation, where it makes sense, and a Grafana dashboard A built-in REST API for server management A built-in MCP Server for LLMs Nidrah AI, an AI Agent to make managing the server easier Real-time server map view Chat auditing and live snooping A new Fake Players Engine with a Node logic system and a new LLM planner for any behavior Just watch the video   If there is interest in this and I'm happy with it, or I get bored (which I always do), I will open-source it. Let me know what you think and if there is some feature you'd like me to implement.
    • Hello everyone!   I offer Java development services for L2-like projects.   I have been working with Java since 2015-2016. During the last years I worked on contract Lineage 2 server development and related infrastructure. My main focus is server-side Java, L2JMobius-based forks, custom systems, packets, datapack/XML, SQL/JDBC, optimization and fixing unstable logic.   Experience with: L2JMobius main/original branch; L2JMobius Essence branch; Lucera interlude; Custom L2-like packs where many things were already changed from the original codebase;   What I can help with: custom systems for your pack; skills / effects / triggers / formulas; NPC / AI / scripts; shops / services / buffer / GM shop logic; items / enchant / rewards / missions; special hunting zones, instances, spawn/zone logic; custom packets and server-side integration with existing client UI changes; server-side integration for existing client-side edits/maps/geodata; SQL/JDBC, XML/datapack, XSD, configs; porting mechanics between branches/chronicles; bug fixing, cleanup, legacy refactoring; performance fixes: memory leaks, race conditions, broadcast/task-manager bottlenecks. other server-side game mechanics;   Examples of larger systems I worked on: clan/economy systems: roles, permissions, auction, shop, warehouse, ranks, seasons, history; PvP/event-like systems: territory/conquest mechanics, rankings, rewards, schedules; hunt pass / season pass / progression systems; account panel / web API for a game project; launcher backend, token-login flow, updater tooling; parsers and analyzers for game/client data; internal testing tools for server-side validation.   I can work with Git, separate branches, commits, pull/merge requests or patches, depending on your workflow. For tasks I usually provide a short note about what was changed and what should be tested.   Format: hourly: 15-20 USD/hour, depending on the task; fixed price per task after checking the requirements/code; small task: from 15 USD; payment: USDT; no revenue share and no unpaid test tasks; a small paid task is usually the best way to check quality and communication first. Contact: Discord: @stroke_dan Telegram @castirom
  • 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..