Solved

need simple explanition for a simple code

Posted on 2002-04-28
2
252 Views
Last Modified: 2010-03-31
i have this function to produce different colors ,
why i need the word final here , what is its function ?
does the function work with out it ?

public static final String[] COLORS={
       "#EEE8AA","#FFEFD5","#FFDAB9","#FFFFFF"
  };
0
Comment
Question by:star4
2 Comments
 
LVL 4

Accepted Solution

by:
pellep earned 50 total points
ID: 6975378
That is not a function, that's a constant (static final). The different string values in the array represent different colors according to the RGB color scheme.
R=Red
G=Green
B=Blue

Thus, #EEE8AA means EE parts red, E8 parts green and AA parts blue. The values are hexadecimal ie ranging from
00 = 0
to
FF = 255
Pure red in this format would look like #FF0000, green would look like #00FF00, blue #0000FF. The color white is an equal mix of the entire spectrum and thus looks like #FFFFFF.

as for the keyword 'final'. That simply tells the compiler that this value cannot be changed in code later
ie

class Test {
private final String finalString = "FINAL STRING";
public void setFinalString(String newVal) {
this.finalString = newVal;
//Compiler will generate an error
//because you are trying to change a 'final' variable
}
}
0
 
LVL 2

Expert Comment

by:vasan_sr
ID: 6976527
when u declare as final we cannot change the value. So we will use final.(final i =10; we cannot change the value. Always i remains 10)

regards
VasanS
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 84
github account with ecipse 1 47
login jsp example 24 47
servlet example 17 29
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question