Step by step to learn Simple JAVA Programe
Showing posts with label java programming. Show all posts
Showing posts with label java programming. Show all posts
Saturday, January 7, 2012
Sunday, December 25, 2011
operator in JAVA
An operator is a symbol that tell the computer to perform certain mathematical or logical manipulation.
Java operators are divided into eight categories: assignment, arithmetic, relational, logical, bitwise,
compound assignment, conditional, and type.
Java operators are divided into eight categories: assignment, arithmetic, relational, logical, bitwise,
compound assignment, conditional, and type.
Assignment Operators =
Arithmetic Operators - + * / % ++ -- Relational Operators > < >= <= == !=
Logical Operators && || & | ! ^
Bit wise Operator & | ^ >> >>>
Compound Assignment Operators += -= *= /= %= <<= >>= >>>=
Conditional Operator ?: For more information visit programming-training.com Wednesday, December 21, 2011
Integer Constants in JAVA
An integer constant refers to a sequence of digits.Their are three types of integer
* Decimal Integer
Decimal integer consist of set of digit, 0 through 9. Example of decimal integer constants are: 156 -321 0 45689
Note : Embeded spaces, commas, and non-digit character are not permited between digits.
# Octal Integers
An octal integer constant consist of any combination of any combination of digit from 0 through 7, with a leading 0.Example of octal integer are:038 0 0564 06891
* Hexadecimal integer
A sequence of digit preceeded by 0x or 0x is considered as hexadecimal integer.In that include alphabets A through F or a through f.Example of hexadecimal integer is0x2 0x9F 0xbcd 0x
Example of Java Constant
class IntConstant
{
public static void main(string args[])
{
int i=10;
System.out.println("Integer Contant Values : " +i);
}
}
Output of a Programme
Integer Contant Values : 10
* Decimal Integer
Decimal integer consist of set of digit, 0 through 9. Example of decimal integer constants are: 156 -321 0 45689
Note : Embeded spaces, commas, and non-digit character are not permited between digits.
# Octal Integers
An octal integer constant consist of any combination of any combination of digit from 0 through 7, with a leading 0.Example of octal integer are:038 0 0564 06891
* Hexadecimal integer
A sequence of digit preceeded by 0x or 0x is considered as hexadecimal integer.In that include alphabets A through F or a through f.Example of hexadecimal integer is0x2 0x9F 0xbcd 0x
Example of Java Constant
class IntConstant
{
public static void main(string args[])
{
int i=10;
System.out.println("Integer Contant Values : " +i);
}
}
Output of a Programme
Integer Contant Values : 10
Wednesday, December 14, 2011
Primitive Data Types
The Java programming language is statically-typed, which means that all variables must first be declared before they can be used.
- byte: The
bytedata type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). Thebytedata type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place ofintwhere their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.
- short: The
shortdata type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As withbyte, the same guidelines apply: you can use ashortto save memory in large arrays, in situations where the memory savings actually matters.
- int: The
intdata type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally the default choice unless there is a reason (like the above) to choose something else. This data type will most likely be large enough for the numbers your program will use, but if you need a wider range of values, uselonginstead.
- long: The
longdata type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided byint.
- float: The
floatdata type is a single-precision 32-bit IEEE 754 floating point.
- double: The
doubledata type is a double-precision 64-bit IEEE 754 floating point.
- boolean: The
booleandata type has only two possible values:trueandfalse. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.
- char: The
chardata type is a single 16-bit Unicode character. It has a minimum value of'\u0000'(or 0) and a maximum value of'\uffff'(or 65,535 inclusive).
Variable in JAVA
Subscribe to:
Posts (Atom)