Zum Hauptinhalt springen
LIVE
CVSS 6.9CVE-2026-137684 | A security flaw has been discovered in eosphoros-ai DB-GPT up to 0.8.3. This affects the function editor_sql_run of the file packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/editor/api_editor_v1.py of the component Editor SQL Run API. Performing a manipulation of the argument db_name results in authorization bypass. It is possible to initiate the attack remotely. The exploit has been released to the public and may be used for attacks. The pull request to fixCVSS 8.7CVE-2026-137992 | libexpat through 2.11.0 contains a denial of service vulnerability in defineAttribute() of lib/xmlparse.c that fails to detect duplicate non-ID #IMPLIED or #REQUIRED attribute declarations. Attackers can supply a crafted XML document with repeated ATTLIST declarations in an internal DTD subset to cause quadratic CPU consumption in storeAtts() during parsing.CVSS 8.5CVE-2026-137994 | Leo through 6.8.10 contains an insecure deserialization vulnerability that allows attackers to execute code by embedding pickled data in unknown XML attributes of .leo outlines. Attackers can place a pickle __reduce__ gadget in a or element attribute that resolveUa passes to pickle.loads, executing code with user privileges when the outline is opened.CVSS 7.0CVE-2026-137995 | FOG Project before 1.6.0.119 contains an information disclosure vulnerability that allows unauthenticated attackers to obtain host tokens from status/hostgetkey.php by supplying a host MAC address. Attackers can present the token to service/hostinfo.php to retrieve decrypted Active Directory join credentials and Windows product keys during deployment windows.CVSS 6.8CVE-2026-137996 | Zettlr before 4.11.0 fails to validate URI schemes in Markdown link targets, allowing attackers to launch arbitrary registered protocol handlers via Electron shell.openExternal without confirmation. Attackers can craft documents whose Ctrl/Cmd-clicked links use smb:// to leak NTLM credential hashes on Windows or invoke custom protocol handlers with attacker-controlled parameters.CVSS 8.5CVE-2026-137997 | HCIPy through 0.7.1 contains an insecure deserialization vulnerability that allows attackers to execute code by supplying crafted .pkl files to read_field, read_grid or read_mode_basis. Because hcipy/util/io.py selects pickle by file extension and calls pickle.load, a __reduce__ gadget in a pupil, apodizer, PSF or mode-basis file runs code with the user's privileges.CVSS 8.5CVE-2026-137998 | Detoxify 0.5.3 through 0.5.4 contains an insecure deserialization vulnerability in load_checkpoint that allows attackers to execute code by supplying a crafted checkpoint file. Attackers can embed a pickle __reduce__ gadget in a .ckpt file loaded via torch.load with weights_only=False to run code with the user's privileges.CVSS 8.5CVE-2026-137999 | JSONSchema2PoPo2 through 3.0.3 contains a code injection vulnerability that allows attackers to inject Python code by supplying JSON Schema default or format values that are written unescaped. Attackers can place a single quote in a string property default to break out of the literal in the generated __init__ signature, executing injected code when the generated module is imported.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Java Rules for Creating a Class, Data Types, and Static Variables

Java is one of the most popular object-oriented programming languages used for developing desktop applications, web applications, mobile apps, and enterprise…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 4 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung

Java is one of the most popular object-oriented programming languages used for developing desktop applications, web applications, mobile apps, and enterprise software. To write efficient Java programs, it is essential to understand the basic concepts such as creating a class, using different data types, and working with static variables. This article explains these concepts in a simple and easy-to-understand manner.









Java Rules for Creating a Class



A class is a blueprint for creating objects. It defines the properties (variables) and behaviors (methods) of an object.






Rules for Creating a Java Class






1. Class Name Should Start with a Letter



A Java class name must begin with an alphabet (A-Z or a-z), underscore (_), or dollar sign ($). However, it is recommended to start with a letter.



Valid Examples:




class Student
class Employee
class _Demo






Invalid Example:




class 123Student












2. Use Pascal Case Naming Convention



Java follows the Pascal Case naming convention for class names, where the first letter of every word is capitalized.



Examples:




  • Student

  • EmployeeDetails

  • BankAccount









3. Class Name Should Not Be a Java Keyword



Reserved keywords cannot be used as class names.



Invalid Examples:




class int
class public
class static












4. Only One Public Class Per File



If a class is declared as public, the filename must match the class name.



Example:



File Name: Student.java




public class Student {
}












5. Curly Braces Define the Class Body



Everything related to the class, such as variables, constructors, and methods, must be enclosed within curly braces { }.



Example:




public class Student {

int id;
String name;

void display() {
System.out.println(name);
}

}












6. A Class Can Contain




  • Variables

  • Methods

  • Constructors

  • Nested Classes

  • Static Members









Example of a Java Class






public class Student {

int id;
String name;

void display() {
System.out.println("ID: " + id);
System.out.println("Name: " + name);
}

public static void main(String[] args) {

Student s = new Student();

s.id = 101;
s.name = "Rahul";

s.display();
}
}






Output:




ID: 101
Name: Rahul












Java Data Types



A data type specifies the type of value that a variable can store.



Java data types are divided into two categories:




  1. Primitive Data Types

  2. Non-Primitive (Reference) Data Types









1. Primitive Data Types



Primitive data types are predefined by Java and store simple values.





















































Data Type Size Example
byte 1 byte 100
short 2 bytes 2000
int 4 bytes 50000
long 8 bytes 9876543210L
float 4 bytes 12.5f
double 8 bytes 45.78
char 2 bytes 'A'
boolean 1 bit true








Integer Example






public class IntegerExample {

public static void main(String[] args) {

int age = 25;

System.out.println(age);
}
}






Output




25












Double Example






public class DoubleExample {

public static void main(String[] args) {

double salary = 45000.75;

System.out.println(salary);
}
}






Output




45000.75












Character Example






public class CharacterExample {

public static void main(String[] args) {

char grade = 'A';

System.out.println(grade);
}
}






Output




A












Boolean Example






public class BooleanExample {

public static void main(String[] args) {

boolean isPassed = true;

System.out.println(isPassed);
}
}






Output




true












2. Non-Primitive Data Types



Non-primitive data types store references to objects rather than actual values.



Examples include:




  • String

  • Arrays

  • Classes

  • Interfaces

  • Objects



Example:




public class StringExample {

public static void main(String[] args) {

String name = "John";

System.out.println(name);
}
}






Output




John












Static Variable in Java



A static variable is a variable that belongs to the class rather than to individual objects. Only one copy of the static variable is created, and it is shared among all objects of the class.



Static variables are declared using the static keyword.






Syntax






class ClassName {

static dataType variableName;

}












Characteristics of Static Variables




  • Belong to the class instead of objects.

  • Memory is allocated only once.

  • Shared among all objects.

  • Can be accessed using the class name.

  • Initialized when the class is loaded.









Example of a Static Variable






public class Student {

int id;
String name;

static String college = "ABC College";

Student(int i, String n) {
id = i;
name = n;
}

void display() {
System.out.println(id + " " + name + " " + college);
}

public static void main(String[] args) {

Student s1 = new Student(101, "Rahul");
Student s2 = new Student(102, "Priya");

s1.display();
s2.display();
}
}






Output




101 Rahul ABC College
102 Priya ABC College






Notice that both students share the same value for the college variable because it is declared as static.









Changing the Value of a Static Variable



If the value of a static variable changes, the updated value is reflected for all objects.




public class Student {

static String college = "ABC College";

public static void main(String[] args) {

System.out.println(college);

college = "XYZ University";

System.out.println(college);
}
}






Output




ABC College
XYZ University












Difference Between Static and Instance Variables
































Static Variable Instance Variable
Belongs to the class Belongs to an object
Shared by all objects Separate copy for each object
Created once Created whenever an object is created
Accessed using the class name Accessed using object references
Declared with the static keyword Declared without the static keyword
Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Community Rating & Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Verwandte Story-Cluster & Quellen (Vektor-KI)

2 Cluster
2 Quellen
OpenAI counter-sues Apple over trade secret theft
AppleInsider News vor 1 Std.
1 weitere Quelle
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Java Rules for Creating a Class, Data Types, and Static Variables

Thematisch verwandte Begriffe: Java, Rules, Creating, Class · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag