Lecture 4


Published on

Notes on core java

Published in: Technology, News & Politics
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture 4

  1. 1. Core Java Debasish Pratihari Java File Structure :  An optional package directive  Zero or more import directive  One or more Class definition Java Keywords : abstract switch package if double byte throws return int final class volatile super continue assert synchronized private implements else case transient short interface finally const * while for default boolean this protected import enum catch try static long float new goto * do break throw public instanceof extends char void strictfp native Note: The * marked keywords are reserved keywords. They may be in action in future. Variable :   A variable is a named memory location that is used to store information. It is able to store data only of one particular type Literals :   Explicit data values present in the program. Each literal is of a particular type. Lecture/core/LF1/04 Page #1 feel the Technology…
  2. 2. Core Java Debasish Pratihari Identifier :        The name given for anything in java Example- variable name, method name, class name etc. It must start with a letter, an underscore( _ ), or dollar sign( $ ). It can’t include operator of java. Is case sensitive. It must not be a java keyword. White space is not allowed in identifiers Primitive Types :  A primitive types is pre-defined by the language and is named by reserved keywords. Primitives Types in Java : Lecture/core/LF1/04 Page #2 feel the Technology…
  3. 3. Core Java Debasish Pratihari Default Values : Note : Compilers never assign a value to local variables of a class. So they must be initialized explicitly before use. Examples of Literals : 25% boolean flag = true; char c = 'D'; byte b = 100; short s = 10000; int i = 100000; Note:  new keyword isn't used when initializing a variable of a primitive type. Primitive types are special data types built into the language  A literal is the source code representation of a fixed value Literals in the form of octal and Hexa :  The integral types (byte, short, int, and long) can be expressed using decimal, octal, or hexadecimal number systems. Examples: int value = 10; int value = 012; int value = 0x0a; Lecture/core/LF1/04 // The number 10, in decimal // The number 10, in octal // Then number 10, in Hexadecimal Page #3 feel the Technology…
  4. 4. Core Java Debasish Pratihari Operators :  Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. Comments :  Comments should be used to give overviews of code and provide additional information that is not readily available in the code itself. Comments should contain only information that is relevant to reading and understanding the program. Java Comment Conventions :      Block comment Single-Line Comment Trailing Comment End-of-Line Comment Documentation Comment Lecture/core/LF1/04 Page #4 feel the Technology…