Results 1 to 1 of 1
-
Using final with method arguments
Java Code:class Gizmo { public void spin() { } } public class FinalArguments { void with(final Gizmo g) { //! g = new Gizmo(); // Illegal -- g is final } void without(Gizmo g) { g = new Gizmo(); // OK -- g not final g.spin(); } // void f(final int i) { i++; } // Can't change // You can only read from a final primitive: int g(final int i) { return i + 1; } public static void main(String[] args) { FinalArguments bf = new FinalArguments(); bf.without(null); bf.with(null); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
Arguments in Main
By CyberFrog in forum New To JavaReplies: 2Last Post: 03-30-2008, 09:37 PM -
Finding arguments of Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-25-2008, 07:04 PM -
repetition of 'arguments'(?)
By Igor in forum New To JavaReplies: 3Last Post: 12-13-2007, 10:08 AM -
Method with final keyword
By javaplus in forum New To JavaReplies: 2Last Post: 11-29-2007, 09:39 AM -
Variable No. of Arguments
By Gajesh Tripathi in forum New To JavaReplies: 2Last Post: 10-31-2007, 02:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks