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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Server is Online – 1,000+ Active Players! We’re excited to announce the addition of a Europe Proxy to improve connectivity for our EU players! Clans can now benefit from VIP Access to help you catch up faster. 🎯 If you're a clan leader with at least 9 active members, join our Discord and open a ticket to claim your VIP rewards!  
    • The Telegram team is rolling out a new batch of Stars-only gifts you’ll be able to mint as NFTs. Don’t miss your chance to join the next Telegram trend and earn from it! Buy Telegram Stars cheap and KYC-free 1 Star from $0.0149 (min. 50 Stars, bulk discounts available) Promo code STARS5 — 5 % off Pay any way you like: bank cards · crypto · other popular methods How to purchase: ➡Online Store — Click ➡ Telegram bot — Click Other services: ➡ SMM panel — Click Regular buyers get extra discounts and promo codes. Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store Use these contacts to discuss wholesale orders, partnerships (current list: https://socnet.bgng.io/partners) or to become a supplier. SocNet — your shop for digital goods and premium subscriptions
    • The Telegram team is rolling out a new batch of Stars-only gifts you’ll be able to mint as NFTs. Don’t miss your chance to join the next Telegram trend and earn from it! Buy Telegram Stars cheap and KYC-free 1 Star from $0.0149 (min. 50 Stars, bulk discounts available) Promo code STARS5 — 5 % off Pay any way you like: bank cards · crypto · other popular methods How to purchase: ➡Online Store — Click ➡ Telegram bot — Click Other services: ➡ SMM panel — Click Regular buyers get extra discounts and promo codes. Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store Use these contacts to discuss wholesale orders, partnerships (current list: https://socnet.bgng.io/partners) or to become a supplier. SocNet — your shop for digital goods and premium subscriptions
    • 📜 • Mass PVP – Craft – Progressive Server (ITEMS, ARMOR, WEAPONS, ETC) 🕹️ • Chronicles: Lineage 2 - Interlude (C6) 🛠️ • Retail status 🕒 • Server Time: GMT -3 🏙️ • Main Town: Giran ✨ • Teleportation for all Towns, Gk Global 🛡️ • NPC BUFFER - GMSHOP B-GRADE - DONATION SHOP - AUCTION MANAGER 🐉 • Epic Bosses: Chaotic Zones 🔁 • Protection respawn: 15 seconds ⏰ • Restart Server: 05:00 AM Today 💸 • RTM allowed between players (ask Staff if in doubt) 📊 SERVER RATES: • EXP: x8 • SP: x10 • Adena: x3 • Seal Stone: x3 • Drop: x3 • Spoil: x5 • Raid EXP/SP/Drop: x3 • Premium Rates: x2 🌐 Website: https://www.l2roosters.com 💬 Discord: https://discord.gg/cUyYXrfy 🔥 Join us now and forge your legacy at Roosters Gaming!
    • Hello, lovely people, how are you? I just finished compiling the L2jFrozen project Rev: 1132 (very old). I don't mind it being too old, since the project is for me and my children. (LAN/Offline) it's not meant to be put online. I want to learn and give my children more comfort when playing. And for my part, I also experiment with the game. My problem is that I don't know much about the subject. I was able to make some basic configurations to my liking and that of my children, but it never compiles or anything like that... I would really need help from you, the community... I simply want to remove all subclass restrictions, remove the restriction on "Overlord, Warsmith, and Dark Elf subclasses with White Elves and vice versa." Thank you very much in advance! Greetings, community.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock