Jump to content

Recommended Posts

Posted

Hello maxcheater!!!!!!!!!

I came today with an idea to make a tutorial. Ofc there are found lot of tutorials on google but like it happend to me before, some of thems are little bored at start and some times make ppl to avoid due to the true java language words used there. In the meaning i tried to adapt this tutorial on my own words as much as i could. Hope this tutorial will help newcomers.

So here we start to learn some basics.

 

9 primitive data types

 

int - a number 32-bite signed between   -2,147,483,648 and 2,147,483,647

short - a 16-bit signed number between -32,768 and 32,767 / unsigned range 0 to 65,535

byte - 8-bit signed number between -128 and 127 / unsigned range 0 to 255

long - 64-bit signed number between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 / unsigned range 0 to 18,446,744,073,709,551,615

double - a number with comma

float – number with comma (is better then double to save memory in large arrays)

char – 1 character

String – commune of characters

Boolean – takes always 2 values,  TRUE or FALSE

 

Symbols and Operators:

; - present the end of an action, statment.

[] - array declaration

"asd" - dopuble quote String message.

'a' - single quote character message.

+= , -= , *= , /=   x += y; is same like x= x+y; ;)

x++ - x=x+1

boolean operatos

x && y- (conditional and)  if and x and y are true, result is true and conversely. If x is false, y is not evaluated.

x & y - (boolean and) if and x and y are true, result is true and conversely. Both x and y are evaluated before the test.

x || y - (conditional or) If x or y are true, the result is true. If x is true, y is not evaluated.

x | y - (boolean or) If x or y are true, the result is true. Both x/y are evaluated before the test.

!x - (boolean not) If x is true, the result is false. If x is false, the result is true.

x ^ y - (boolean xor) If x is true and y is false, the result is true. If x is false and y is true, the result is true. Otherwise, the result is false. Both x and y are evaluated before the test.

How to writte a variable.

 

Type    name of variable

Int        value1;  (remember a variable always end with [ “ ; “])

Initialize    (give value to variable)

Value1=1000;

Other examples:

int value 1=  1000;

long a= 1234567810L;

float f=297.5F;

double d= 179999.8;

short b= 2945;

byte m=27;

char e=’E’;

String s=”erol”; when you create a String object you can’t change it anymore their values.

Boolean q=true; or q=false;

OPERASTORS

Operator                           Description                                             true example                      false example

<                                         Less then                                               3 < 8                              8 < 3

>                                     Greater then                                               4 > 2                              2 > 4  

==                                       Equal to                                                 7 == 7                             3 == 9    

<=                                          Less then or equal to                             5 <= 5                             8 =< 6    

>=                                             greater then or equal to                      7 >= 3                             1 >= 2        

!=                                       not equal to                                             5 !=6                               3 != 3

Comments in Java

Line comments – start with 2 slashes. And is when we comment 1 line.

Block comments - start with /* and end with */ when we comment in more then 1 line.

Java doc comment – start with /** and end with */ can use this to generate doc with a program named javadoc.

Rules how to put the name of a class.

1. Name must be same with the name of file. Even the caps.

2. Name can contain numbers, char, @, $.

3. Cannot use as class name words like (int, boolean, String etc).

4. Name of class cannot start with a number.

5. Cannot use words True, False, null as name of a class.

 

When starting writing on java you should know some specific things.

A class start as:  public class nameofclass

After it you writte {

Remember every { need another }. So if you open 3 { you need to close with 3 }.

An example.

public class test
{
     public static void sum()
        {
              int value1=20;
              int value2=50;
              int=sum=value1+value2;
       System.out.println(“sum is” +sum);
        } 
}

 

METHODS* - are instructed 1 time and called many times.

How to construct a method:

you can find more about methods here ---> Java Methods

 

declaration:

 

{

Body of the method

}

declaration

a) Public or private

b) Static (method that never change)

c) Void (method which does not turn value

Type of value ( when we have method that turn value)

d) Name of method

e) (

f) Arguments

g) )

 

CREATING METHODS WITH NO ARGUMENTS

public class test
{
public static void sum()
{
	int value1=20;
	int value2=50;
	int sum=value1+value2;
	System.out.println ("sum is" +sum);
}
}

Now this time we create one with argument.

public class test
{
public static void sum (int 200)  
{
	int value2=50;
	int sum=value1+value2;
	System.out.println("sum is" +sum);
}
}

Now method which  turn values.

public class test
{
public static int sum()
{
	int value1=20;
	int value2=50;
	int sum=value1+value2;
	System.out.println(sum());
	return sum;
}
}

 

Here we see that at public static we don’t have anymore void. Rember when there is void means that cannot turn values.

 

Method that return value with 1 argument.

 

public class test
{
	public static int sum(int value1)
	{

		int value2=50;
		int sum=value1+value2;
		System.out.println(sum(20));
		return sum;
	}

}

 

Set and get methods.

1*

public class test 
{
private int age;
public String getage;
public int getmosha()
{
	return age;
}
public void setage (int m)
{
	age=m;
}
}

2*

public class test3 
{
public static void main(String[]args)
{
	test isi=new test();
	isi.setage(22);
	System.out.println ("Age is"+isi.getage);
}
}

*Isi – is just a random name, you can choose whatever you want.

 

An example of set and get but now we add name and rank.

http://pastebin.com/Ryw1g1xL

we can also do it in a simple and shorter way. We delete the set method.

http://pastebin.com/VAke8m8S

you see in both links this: test isi=new test();  ----> means that 2 classes are connected together. and 1 mistake test class make the second one to give error.

 

Structures switch and if/else.

 

Taking a character from keyboard

1) Main()throwsException

2) Declariation of the character  (char e;)

3) Initialize of the character with the value token on keyboard

System.in.read(); - taking character from keyboard

out – screen / in- keyboard

read – method that read  / println – method that post smth

I’m gona show you an example that while you press smth on keyboard it say you if you typed or not.

1st example is with if and if else. Remember, it always start with if and end with else.

http://pastebin.com/tJtEFgAD

now let’s see the same but this time with switch structure.

http://pastebin.com/qKQQ87CP

you may notice that now in place of if we got case and in place of else we got default.

Vectors

type[]name=new type

when we have a group of indications with same name and type we can declare with a vector.

Example:

int erol=new erol[7];     // 0-6 (n-[n-1])

 

public class test3
{
public static void main(String[]args)
{
	int[]isi=new int[4];
	for (int i=0;i<=6;i++)
	{
		isi[i]=i*2;
		System.out.println(isi[i]);
	}
}
}

Take this example: http://pastebin.com/SX5UKHT5

You see it order some nrs written in random way.

To make it as a descending order you must change last for like this:

Was: for (int i=0;i<v.length;i++) make it for (int i=14;i>0;i--). (you see that the second one no need any other code, just math skill)  ;)

for those ppl who hate math here is an example: sort vector using comparator example

 

 

 

 

Posted

This code present the votes for some candidates. On this case we have 4 candidates and we gonna make a code that when we press 1 go +1 vote for candidate 1 and so on for all candidates.

 

import javax.swing.JOptionPane;

public class votat 
{
public static void main(String[]args)
{
	int numcandidates=4;
	int[] votes= new int[numcandidates];
	boolean processing=true;
	while(processing)
	{
		int v=new Integer(JOptionPane.showInputDialog("Vote for (0,1,2,3):")).intValue();
		if (v>=0&&v<votes.length)
		{
			votes[v]=votes[v]+1;
		}
		else
		{
			processing=false;
		}
		for (int i=0;i!=votes.length;i=i+1)
			System.out.println("Candidate"+i+"has"+votes[i]+"votes");
	}
}
}

 

processing=false; ---> means that if you press a wrong button it quit recognizing it as an illegal vote ;)

 

 

here i'm going to present a simple calculator. simpler then the ones on google.  ;)

 

import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.TextField;

public class test22 extends Applet
{
Button b=new Button("additon");
Button b1=new Button("divide");
Button b2=new Button("multiplication");
Button b3=new Button("divide");
TextField t1=new TextField(10);
TextField t2=new TextField(10);
Color c=new Color(100,20,30);
int rez;
public void init()
{
	setBackground(c);
	add(t1);
	add(t2);
	add(b);
	add(b1);
	add(b2);
	add(b3);
}
public boolean action(Event e,Object args)
{
	String s1=t1.getText();
	String s2=t2.getText();
	int nr1=Integer.parseInt(s1);
	int nr2=Integer.parseInt(s2);
	if (e.target==b)
		rez=nr1+nr2;
	if(e.target==b1)
		rez=nr1-nr2;
	if(e.target==b2)
		rez=nr1*nr2;
	if(e.target==b3)
		rez=nr1/nr2;
	repaint();
	return true;
}
public void paint(Graphics g)
{
	g.drawString("rezultati="+rez,50,80);
}
}

Button b=new Button("additon"); this make a button just like in a real calculator. like this we make and for divide, multiplication and deduction.

TextField t1=new TextField(10); is a text field where you will writte the numbers. (10) is the size of this textfield.

Color c=new Color(100,20,30); this is color of the pop up window you will see after excecuting.

if (e.target==b)  means that if you pres button b which correspond on addition (you will see it as addition on window) ...

... will be take this action ----> rez=nr1+nr2;

and so one for other actions.

Note* the calculator will show results only for int numbers. so if you type 2 / 8 it will show as 0.

to make it show even numbers with comma we have to change int to double.

on this case need to change: from int rez; to double rez;

from int nr1=Integer.parseInt(s1); to double nr1=Integer.parseInt(s1);

and so even for nr2.

g.drawString("rezultati="+rez,50,80); 50 and 80 put the result in which position you want. starting from 0,0 the start point (upper-left). just change the numbers how you want and you see the changes yourself.

 

To be continued...

 

Posted

You'll teach me some java ofc,but thanks for your try.

You will help many newbiew who they want to learn the basic of java

Posted

to be continued (is not finished yet)...  :)

and why you post not finished works? anyway Gj...

 

EDIT:

short: −32,768 to +32,767 and 0 to +65,535

Posted

and why you post not finished works? anyway Gj...

coz i have more to say. like applets for example which i love a lot.

ofc like i mention before, there are lot of guides on goole, but their true english and java language make ppl little confuse. I just hope that with this tutorial i motivate ppl learn Java coz its damn really attractive language.

going to post how to make the calculator, the translator, clock etc etc......

Stay tunned and thnx for the good words guys.

Posted

EDIT:

0 to +65,535

this is unsigned range. btw thnx gonna add even unsigned ranges.

Posted

i'm studying html, but i never had the chance to learn a new language... like Java.

i've already expressed myself "inside", awsome guide Erol. It will help noobs like me to learn some java.

Posted

 

int - a number 32-bite signed between  -2,147,483,648 and 2,147,483,647

short - a 16-bit signed number between -32,768 and 32,767 / unsigned range 0 to 65,535

byte - 8-bit signed number between -128 and 127 / unsigned range 0 to 255

long - 64-bit signed number between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 / unsigned range 0 to 18,446,744,073,709,551,615

 

Aka Integers.

 

double - a number with comma

float – number with comma (is better then double to save memory in large arrays)

 

 

Aka Floating Points.

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

    • Update: Advanced Rate Limiting Rate limiting is now applied to: Login attempts Account registration Password recovery Email confirmation resends WhatsApp verification Checkout access The system maintains independent counters by IP address and user identity, helping prevent traditional brute-force attacks as well as distributed credential-stuffing attempts using multiple proxies. Brute-Force and Credential-Stuffing Protection Protection is not limited to the visitor's IP address. The system also tracks attempts associated with the account, username, or email address, reducing the effectiveness of attacks performed through rotating IP addresses, proxies, or VPN services. Global HTTP Security Headers Security headers are applied across the entire website: X-Frame-Options X-Content-Type-Options Referrer-Policy HTTP Strict Transport Security These headers help protect the website against clickjacking, MIME-type confusion, insecure referrer exposure, and HTTP downgrade attempts. Secure Error Handling Internal exceptions are recorded in protected security logs while visitors receive sanitized error messages. This prevents the accidental exposure of: Internal file paths Database information SQL errors Server configuration Application stack traces Private Storage Exposure Monitoring The system automatically checks whether the private storage directory is publicly accessible in production. If exposure is detected, a security warning is recorded for the administrator without interrupting the website. This directory may contain licensing information, rate-limit records, and security logs and must never be publicly accessible. OAuth Request Protection Google and Facebook authentication flows use cryptographically random state values stored in the user's session. Returned state values are validated using constant-time comparison, helping prevent OAuth request forgery and unauthorized account-linking attacks. Telegram Authentication Validation Telegram login information is protected through: HMAC signature validation Constant-time hash comparison Authentication timestamp verification Expired-login rejection Secure Verification Tokens Email, password recovery, and WhatsApp verification systems include: Cryptographically secure random tokens Hashed WhatsApp verification codes Automatic expiration Limited verification attempts Resend cooldowns One-time token invalidation Account Activation Protection When email or WhatsApp verification is required, the game account remains restricted until all required verification steps are completed. Unverified users cannot bypass the confirmation process through standard or social login. Secure Upload Processing Administrative image uploads include: Real MIME-type inspection Image-content validation File-size limits Extension allowlists Server-generated random filenames Rejection of invalid or disguised files Original user-provided filenames are never used as the final stored filename. Path Traversal Protection Theme and template identifiers are restricted to validated slugs and must exist in the internal list of allowed themes. This prevents directory traversal and unauthorized local-file access through manipulated template names. Atomic Ticket Transfer Protection Ticket transfers use transactional and durable delivery processing. The balance is conditionally debited, the delivery is recorded before communication with the game database, and failed deliveries remain pending for safe reprocessing. This helps prevent: Free-item delivery Inconsistent balances Duplicate delivery Partial transaction failures Lost transfer records Concurrent Balance Protection Administrative balance adjustments use database transactions and row-level locking. This prevents simultaneous balance operations from overwriting each other or creating inconsistent account balances. Secure Redirect Handling Redirect values are sanitized against header injection, and external redirects are restricted to HTTPS destinations. Password Security Improvements The website uses modern password hashing for player-panel accounts and bcrypt with a configurable cost for supported game-server account systems. Compatibility is included for game-server implementations requiring the $2a$ bcrypt prefix. Duplicate Payment Prevention Built-in protections include: Idempotency control Transaction reference validation Payment status verification Unique external payment references Database transactions and rollback Durable payment history Completed-order verification These protections prevent: Double credits Repeated processing Duplicate payment callbacks Incomplete financial operations Signed Payment Callback Protection Payment callbacks are protected through: HMAC-SHA256 authentication Constant-time signature comparison Signed callback timestamps Callback freshness validation Shared callback secrets This helps prevent forged payment notifications, callback manipulation, and replay attacks. SQL Injection Protection The database layer uses: PDO Prepared statements Parameter binding Controlled internal allowlists for dynamic identifiers User-controlled values are not directly concatenated into SQL queries. XSS Protection Output and form data are protected through: HTML escaping Attribute escaping Input filtering HttpOnly session cookies MIME-sniffing protection Frame embedding restrictions These measures reduce the risk of Cross-Site Scripting, malicious HTML injection, session theft, and clickjacking. CSRF Protection Sensitive forms and administrative operations use session-based CSRF tokens. Requests without a valid token are rejected, helping prevent unauthorized actions performed through malicious external websites. Secure Session Protection The session system includes: HttpOnly cookies Secure cookie support SameSite restrictions Session ID regeneration Authentication state validation Session timeout controls These protections reduce the risks of session fixation, session theft, and unauthorized account reuse. reCAPTCHA Protection Google reCAPTCHA may be enabled on sensitive public forms to reduce: Automated account registrations Spam submissions Bot login attempts Automated password recovery abuse Confirmation Resend Limits Email and WhatsApp confirmation resends are protected through: Cooldown periods Rate limiting Expiring verification codes Attempt counters This prevents verification-message flooding and excessive external API usage. Licensing and Anti-Cloning Protection The website includes centralized licensing controls with: License-key validation Domain binding Signed license responses Cached license validation Temporary offline grace period Circuit-breaker protection Unauthorized-domain rejection These measures help prevent unauthorized installation, cloning, and redistribution of the system.
    • Tool that allows you to download the Lineage 2 game client directly from the official publisher CDNs. It fetches the CDN's file list and downloads every patch file, decompresses it (LZMA / Zip) and writes the finished client to disk — and can resume or repair an existing installation instead of starting over. It runs several client downloads at once through a batch queue, so you can prepare multiple regions or versions in a single session.   Supported: NCSoft CDNs (TW / KR / JP / NA) and  4game CDNs(RU / EU)   Download: https://drive.google.com/file/d/11SDcNASqO2GKOBT79LFu7mqvSRSJZvBS
    • https://l2avokado.com/ Hello everyone,   After some time of development, we've decided to open L2Avokado to the public in its current development stage. We're looking for players who enjoy Interlude and would like to help shape the project before its official release.   This isn't a "launch" announcement. Instead, we're inviting the community to log in, explore the server, test the systems we've built, and provide honest feedback. Whether it's bug reports, balance suggestions, progression ideas, or quality-of-life improvements, we'd love to hear them.   Our goal has always been to create an Interlude server that feels familiar while offering a fresh progression experience. We've intentionally avoided custom weapons, armor, and client modifications. Instead, we've focused on redesigning progression through reworked hunting grounds, quests, crafting, and gameplay systems while remaining compatible with a clean Interlude client.   At this stage, the core progression path has been implemented, including the main hunting grounds, quests, custom systems, and events. However, as the project is still under active development, there will inevitably be bugs, balance issues, and areas that require further polishing.   This is exactly why we'd like your help.   We're looking for players who are willing to: Test gameplay and progression. Report bugs and exploits. Suggest balance improvements. Share ideas for new features or quality-of-life changes. Help us build a server that the community genuinely enjoys playing.   The Client and System downloads are already available on our website, so you can jump straight into the game. We're also working on a dedicated launcher that will simplify installation and future updates.   If you're interested in helping develop a unique Interlude project and want your feedback to genuinely influence the direction of the server, we'd love to have you with us.   We look forward to seeing you in-game and hearing your thoughts on Discord. https://l2avokado.com/
  • 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..