Search This Blog

Wednesday, 24 May 2017

Java Language Fundamentals

Java Language Fundamentals

Identifiers
  • A name in a program is called an identifier.
  • Identifiers can be used to denote classes, methods, variables, and labels.
  • In Java an identifier is composed of a sequence of characters, where each character can be either a letter, a digit, a connecting punctuation (such as underscore _), or any currency symbol (such as $, ¢, ¥, or £). However, the first character in an identifier cannot be a digit.
  • Identifiers in Java are case sensitive, for example, price and Price are two different identifiers.

Examples of Legal Identifiers: number, Number, sum_$, bingo, $$_100, mål, grüß 
Examples of Illegal Identifiers: 48chevy, all@hands, grand-sum

Keywords
  • Keywords are reserved identifiers that are predefined in the language and cannot be used to denote other entities.
  • All the keywords are in lowercase, and incorrect usage results in compilation errors.



Literals
  • A literal denotes a constant value, that is, the value a literal represents remains unchanged in the program. Identifiers can be used to denote classes, methods, variables, and labels.
  • Literals represent numerical (integer or floating-point), character, boolean or string values. In addition, there is the literal null that represents the null reference.

Examples of literals
  • Integer 2000, 0, -7 
  • Floating-point 3.14, -3.14, .5, 0.5
  • Character 'a‘, 'A‘, '0‘, ':‘, '-‘, ')' 
  • Boolean true, false 
  • String "abba“, "3.14“, "for“, "a piece of the action“

Comments
A program can be documented by inserting comments at relevant places. These comments are for documentation purposes and are ignored by the compiler.
Java provides three types of comments to document a program:
  • A single-line comment: // ... to the end of the line
  • A multiple-line comment: /* ... */
  • A documentation (Javadoc) comment: /** ... */

Primitive data types
Primitive data types in Java can be divided into three main categories:
  • Integral types— represent signed integers (byte, short, int, long) and unsigned character values (char)
  • Floating-point types (float, double)— represent fractional signed numbers
  • Boolean type (boolean)— represent logical values


Primitive data values are not objects. Each primitive data type defines the range of values in the data type, and operations on these values are defined by special operators in the language.

Variable declaration
A variable stores a value of a particular type. A variable has a name, a type, and a value associated with it. In Java, variables can only store values of primitive data types and references to objects. Variables that store references to objects are called reference variables.

Declaring and Initializing Variables
Variable declarations are used to specify the type and the name of variables. This implicitly determines their memory allocation and the values that can be stored in them.
  • char a, b, c; // a, b and c are character variables.
  • double area; // area is a floating-point variable.
  • boolean flag; // flag is a boolean variable.

A declaration can also include initialization code to specify an appropriate initial value for the variable:
  • int i = 10; // i is an int variable with initial value 10.
  • long big = 2147483648L; // big is a long variable with specified initial value.

Object Reference Variables, An object reference is a value that denotes an object in Java. Such reference values can be stored in variables and used to manipulate the object denoted by the reference value. Before we can use a reference variable to manipulate an object, it must be declared and initialized with the reference value of the object.
  • Pizza yummyPizza; // Variable yummyPizza can reference objects of class Pizza.
  • Hamburger bigOne; // Variable bigOne can reference objects of class Hamburger
  • Pizza yummyPizza = new Pizza("Hot&Spicy"); // Declaration with initializer.

32 comments:

  1. It’s always so sweet and also full of a lot of fun for me personally and my office colleagues to search your blog a minimum of thrice in a week to see the new guidance you have got.
    Best Java Training Institute Chennai

    ReplyDelete
  2. Those rules moreover attempted to wind up a decent method to perceive that other individuals online have the indistinguishable enthusiasm like mine to get a handle on incredible arrangement more around this condition. dotnet training in bangalore
    Dotnet developer

    ReplyDelete

  3. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.

    rpa training in Chennai

    rpa training in anna nagar | rpa training in marathahalli

    rpa training in btm | rpa training in kalyan nagar

    rpa training in electronic city | rpa training in chennai

    rpa online training | selenium training in training

    ReplyDelete
  4. Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post
    Python training in marathahalli
    Python training in pune
    AWS Training in chennai

    ReplyDelete
  5. I believe we could greatly benefit from each other. If you happen to be interested, feel free to shoot me an e-mail. I look forward to hearing from you! Great blog by the way!
    fire and safety course in chennai

    ReplyDelete
  6. such an great post and amazing tips about semrush because i like it and thank you. keep it up.
    For Premium Accounts at cheap rate check this site premium Accounts Seller

    Netflix premium account -- Netflix premium Account

    Premium Accounts at cheap -- Hotstar premium Account



    Hotstar premium account -- Hotstar premium Account

    ReplyDelete
  7. https://www.vox.com/users/MrTechnoMind

    ReplyDelete
  8. Theodore Hall (Ted) is a retired manufacturing executive who has gotten into Internet Marketing कल्याण मटका रिजल्ट Kalyan matka Satta Result

    ReplyDelete
  9. Annabelle loves to write and has been doing so for many years.meri recipe indnewstv fullinhindi buy seo service

    ReplyDelete
  10. Be a part of India's fast growing institution . As our institution is providing CS executive classes and free CSEET classes . So don't waste your valuable time and contact us or visit our website at https://uniqueacademyforcommerce.com/

    ReplyDelete
  11. Thanks for sharing such a worthy information. Keep update like this.....
    IELTS Coaching in Hyderabad
    IELTS Coaching in Bangalore

    ReplyDelete
  12. Tired of sharing long, nasty URLs? This app immediately shortens URLsCRYPTO NEWS 24X7

    ReplyDelete
  13. This post is so interactive and informative.keep update more information...
    Salesforce Training in Tambaram
    Salesforce Training in Chennai

    ReplyDelete
  14. It is extremely nice to see the greatest details presented in an easy and understanding manner.
    data science institutes in hyderabad

    ReplyDelete
  15. Save day speech college usually. Side some price data certain daughter kind. Personal final move result step.insightminutes.com

    ReplyDelete
  16. Customer various position recent development hit morning. Already message use level nor what ball bank.trending-updates

    ReplyDelete