Declaring Variables and Access Modifiers - Java Object Oriented Design

Java examples for Object Oriented Design:Access Level

Introduction

Java implements eight primitive data types.

Declarations for Primitive and String Types

Demo Code

public class Main { 
     public static void main (String[] args) { 
         boolean BooleanVal = true;  /* Default is false */ 
 
         char charval = 'G';     /* Unicode UTF-16 */ 
         charval = '\u1990';     
 
         byte byteval;       /*  8 bits, -127 to 127 */ 
         short shortval;     /* 16 bits, -32,768 to 32,768 */ 
         int intval;         /* 32 bits, -2147483648 to 2147483647 */ 
         long longval;       /* 64 bits, -(2^64) to 2^64 - 1 */ 
 
         float   floatval = 1.123456F; /* 32-bit IEEE 754 */ 
         double doubleval = 1.12345678987654; /* 64-bit IEEE 754 */ 
 
         String message = "Darken the corner where you are!"; 
         message = message.replace("Darken", "Brighten"); 
     } //  w  w w.j  ava2 s. c  o  m
}

Related Tutorials