Java Language Fundamentals

Java Language Fundamentals

Hi guys, here comes the third article in the series of Java articles series. In this article basically we will be talking about basic terminologies in Java Programming language.

To prepare a java application, we need some fundamentals entities provided by the Java Programming Language. They are

  1. Tokens
  2. Data Types
  3. Type Casting
  4. Java Statements
  5. Arrays

  • Tokens
  • Smallest logical unit of a program is called as “lexeme”
  • The collection of lexeme comes under a particular group called as “Token”
  • Example:

 int a = b +c *d;        

  • Lexeme: int, a, =, b, +,c,*, d,; —> 9 lexemes are there in above statement.
  • Tokens used in above program

  1. Data Types: int
  2. Identifiers: a,b,c,d
  3. Operators: =, + , *
  4. Special Symbol: ;

  • Types of tokens
  • There are 4 types of tokens in java.
  • To write a java application, Java has given the following list of tokens

  1. Identifiers.
  2. Literals
  3. Keywords/ Reserved Words
  4. Operators

  • Identifiers
  • Identifier is a name assigned to the programming elements like, variables, methods, classes, abstract classes, interfaces ... etc.
  • example:

int a = 10;

int --> Data Type
a ---> variable(identifier)
= --> Operator
10 --> Constant
; --> Terminator        

  • To provide identifiers in Java Programming language, there is set of rules & regulations given by Java. they are

  1. Identifiers should not be started with any number.
  2. Identifiers may be started with an alphabet(a-z or A-Z), ‘_’ symbol, ‘$’ symbol, but subsequent symbols may be a number, alphabet, any symbols etc

  • example:

int eno= 101; //valid
int 2eno = 102; // Invalid 
String _eaddr = "Bangalore";// Valid
float $esal = 78000.00f;// Valid 
String emp9no = "E-IN-090" //Valid
String emp_Name = "Dipika" // Valid
float emp2$Sal= 547793.00f // Valid        

  1. Identifiers doesn’t allows all the operators & all the special symbols except _ & $

int empNo = 222;//valid
int emp+No = 343;//
String emp*Name = 'dipika' // Invalid
String emp@Bangalore = 'dipika' //Invalid
String emp.Addr = 'Bangalore'// Invalid
String emp_Addr = "Bangalore" // Valid         

  1. Identifiers doesn’t allows spaces in between or in the middle of the name.
  2. We can’t create duplicate identifiers in the same scope, but we can create duplicate identifiers in different scopes.
  3. In java applications, we can use all predefined class names and interface names as identifiers.

class Identifiers{
	public static void main(String[] args){
		int Exception = 10;
		System.out.println("the exception value is:" + Exception);
	}
}
>javac identifiers.java

>java Identifiers
the exception value is:10        

  1. Note: Once if we declare “System”[Class Name] as an integer variable then we must use that “System” name as a integer variable only in the remaining of the program.
  2. By chance also if we use “System” as a class name then the compiler will raise an error.
  3. If we want to use “ System” as class name then we need to use its fully qualified name.

  • Fully Qualified Name: Specifying class names and interface names along with package names is called as Fully Qualified Name.

//using any predefined class , variable, methods as a custom identifier
class Custom_Identifier{
	public static void main(String[] args){
		int Exception = 10;
		int System = 20;
		//System.out.println("the exception value is:" + Exception);
		java.lang.System.out.println("The exception value is : " + Exception);
		java.lang.System.out.println("The system value is : " + System);
	}
}        

  • Along with the above rules of Identifiers, Java has provided a set of suggestions as well to use identifiers in our java program.

  1. In java app, it is suggestible / encouraged to provide identifiers with a particular meaning.

String ppp = "dipika" // not suggested
String name = "dipika" // suggested        

  1. In java applications, we don’t have any restrictions over the length of the identifiers, we can declare identifiers with any number of length, but it’s highly recommended to provide length of identifiers about 10 symbols.

String permanentaddresofBangalore = "HSR Layour"// not suggestible/ recommended
String permAddrBlore = "JayaNagar"// recommended 
        

  1. If we have multiple words in single identifier, then it is suggestible to separate multiple words, with a special notation like _ symbols.

  • Example:

String permAddrBlore = "JayaNagar"// not recommended
String perm_Addr_Blore = "Majestic"// recommended         

  • Summary

  1. Introduction to Identifiers.
  2. Rules of Identifiers
  3. Suggestible / Optional rule to create a identifier.

#java #javadevelopment #softwareengineering #fresher #programming #dailylearning

#dailycoding

To view or add a comment, sign in

More articles by Praveen Kumar

  • Differences between Abstraction & Encapsulation in Java

    Understanding the concepts of abstraction and encapsulation is crucial for any Java developer. However, these concepts…

  • Unlocking Backend Brilliance: A Journey into NestJS for Creating RESTful API

    If you're just starting out on your journey in backend development, you're in for a treat. NestJS is not your average…

  • All About Rate Limiter

    What is Rate Limiter? A rate limiter is a system component that restricts the rate at which requests are made to a…

  • How to integrate ChatGPT in your web application

    So, let's talk about trending #chatgpt . I will try to tell everything about ChatGPT & it's capabilities.

  • Reserved words & Operators in Java

    Keywords / Reserved words Hi guys, I am back with another topic on Java, which is 5th article of our ongoing java…

  • Number System in Java | Article - 4

    Hi, guys so in previous article of our Java Series we saw language fundamentals of Java. If you are new to this article…

  • REST API using Express & MongoDB

    Getting Started The only thing we need to get started with this project is a blank folder with npm package initialized.…

  • Naming Conventions in Java

    Java Article Series - 2 So In continuation of the previous article on Java, today we will be going through Java naming…

  • Introduction to Java

    Java Series Article - 1 Hi guys here I am introducing java article series in which I will try to cover the things I…

  • Basics of Web Pages

    HTML, defines the content of every web page on the internet. By "marking up" our raw content with HTML tags, we are…

Insights from the community

Others also viewed

Explore topics