variables_final_keyword.htm

Using Eclipse

import java.util.*;
import java.io.*;
//javac test_operator.java
public class test
{
private int player_no = 12;
public test()
{ System.out.println("This is a constructor with no param");
}
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("Type something :");
String str = "";
str = br.readLine();
test t = new test();
t.get_no(str);
}
public void get_no(String str)
{
final int player_no = 24;
this.player_no = player_no;
System.out.println(str + " Your Unform No : " + player_no);
}

}

command line code

import java.util.*;
import java.io.*;
//javac test_final.java
public class test_final
{
private int player_no = 12;
public test_final()
{ System.out.println("This is a constructor with no param");
}
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("Type something :");
String str = "";
str = br.readLine();
test_final t = new test_final();
t.get_no(str);
}
public void get_no(String str)
{
final int player_no = 24;
this.player_no = player_no;
System.out.println(str + " Your Unform No : " + player_no);
}

}

import java.util.*;
import java.io.*;
//javac test_final_2.java
public class test_final_2
{
private int player_no = 12;
public test_final_2()
{ System.out.println("This is a constructor with no param");
}
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("Type something : ");
String str = "";
str = br.readLine();
test_final_2 t = new test_final_2();
t.method_2();
t.get_no(str);
//calling method_2() again
t.method_2();
}
public void get_no(String str)
{
final int player_no = 24;
this.player_no = player_no;
System.out.println(str + " Your Unform No now : " + player_no);
}
public void method_2()
{
String str = "public player_no was : " ;
System.out.println(str + player_no);
}
}