Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2006, 10:03 PM
Authorized User
 
Join Date: Sep 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Modifier use within the viod main()

Dear forumers...

I am new to java and just trying out basic programs. I have just learnt about the access modifiers....... but as soon as I tried to use them in the void main() I got an error saying that the modifier public/private is not allowed here !!

Could anyone kindly explain to me why.... ?

------------------------------------------------------

public static void main()
{
....
private int x ....
}

error: modifier private not allowed here.
--------------------------------------------------------------

Much appreciated.
Ibn Aziz
 
Old June 3rd, 2006, 05:21 AM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

take the private out of the main() method. In the method the variable is local, and that lifescope only in the method.

 
Old June 3rd, 2006, 10:08 PM
Authorized User
 
Join Date: Sep 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx....





Similar Threads
Thread Thread Starter Forum Replies Last Post
Main Builder Delthor Java Basics 0 January 3rd, 2008 07:41 AM
CS0260: Missing partial modifier on declaration of belete ASP.NET 2.0 Basics 11 November 15th, 2007 04:04 PM
Friend access modifier acts as private sandeep ASP.NET 2.0 Professional 2 July 19th, 2007 07:35 AM
Unknown Modifier Error - Regular Expression Beebs BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 March 20th, 2007 05:48 PM
Modifier Keys shadowpug VB.NET 2002/2003 Basics 2 March 31st, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.