Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

How to declare a constant in Java?

The statement of declaring a constant in Java is final

Code:

final static double PI = 3.14;
final int DAY = 24;

PLEASE note that the constant name should be in CAPITAL LETTERS.

Starting Java

This is my first post about Java programming language, I'll start this post with variables and how to declare them.

int i;
int i,j,k;
int m = 1, s = 2, k = 40;

float r;
double w = 2.5;

String myString = "Hello";
String mySt = 'This is wrong'; // Wrong declaration of String ... it should be with double qoute