Data types in JAVA Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java: Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays. Java Primitive Data Types: In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in Java language. Java is a statically-typed programming language. It means, all variables must be declared before its use. That is why we need to declare variable's type and name. There are 8 types of primitive data types: boolean data type byte data type char data type short data type int data type long data type float data type double data type Boolean Data Type The Boolean data type is used to store only ...
Java Switch Statement The Java switch statement executes one statement from multiple conditions. It is like if-else-if ladder statement. The switch statement works with byte, short, int, long, enum types, String and some wrapper types like Byte, Short, Int, and Long. Since Java 7, you can use strings in the switch statement. In other words, the switch statement tests the equality of a variable against multiple values. Points to Remember There can be one or N number of case values for a switch expression. The case value must be of switch expression type only. The case value must be literal or constant . It doesn't allow variables . The case values must be unique . In case of duplicate value, it renders compile-time error. The Java switch expression must be of byte, short, int, long (with its Wrapper type), enums and string . Each case statement can have a break statement which is...
Unicode System Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages. Why java uses Unicode System? Before Unicode, there were many language standards: ASCII (American Standard Code for Information Interchange) for the United States. ISO 8859-1 for Western European Language. KOI-8 for Russian. GB18030 and BIG-5 for chinese, and so on. Problem This caused two problems: A particular code value corresponds to different letters in the various language standards. The encodings for languages with large character sets have variable length.Some common characters are encoded as single bytes, other require two or more byte. Solution To solve these problems, a new language standard was developed i.e. Unicode System . In unicode, character holds 2 byte, so java also uses 2 byte for characters. lowest value:\u0000 highest value:\uFFFF Next Topic: Operators In java Happy Coding
Comments
Post a Comment