Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent keyword for extern in java?

Tags:

java

I have one public static variable in one file and how can I export the same variable to other files?

For ex:-

file1.java

public final static int buf = 256;

file2.java

How can I access the variable "buf" in this file?

like image 442
Thangaraj Avatar asked Jul 26 '11 13:07

Thangaraj


1 Answers

File1.buf. More generally: ClassName.FIELD_NAME. A few notes

  • use CAPITAL_LETTERS to name your static final fields (BUF)
  • use static final rather than final static (not crucial, but it is a widely accepted style)
like image 196
Bozho Avatar answered Sep 24 '22 10:09

Bozho