Results 1 to 3 of 3
  1. #1
    Jadellll is offline Member
    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Default public declaration ('undeclaring')

    This is probably more simple than the title, but here goes:
    I have a class file that created VarClass as a public class.

    public class VarClass
    //{main{stuff}}

    It compiles and works fine. But if I try to make, say, version 2 of it with the same named public class, javac simply says it should be declared in the first class. So my questions are: 1:doesn't it take ram space to remember that? and 2: how can i clear the computer of remembering. And if its a file that has to be edited, how can I tell java to do that?

    I've heard of garbage collecting but I'm still learning so thanks.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Change the name of the version_2 class or remove the version_1 source file from the current directory or put it into another folder in the current directory. Java cannot deal with multiple files with the same public, outer class_name in the same folder at compile time.
    The garbage collector functions during runtime to remove objects from the jvm (java virtual machine) after there are no more references to them (the objects).

  3. #3
    Jadellll is offline Member
    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Default

    I deleted the text file and class file, but it still remembers that it should be initialized in a different file/class. I want to know where it remembers it, so I can clear it if I need to. Creating a new name for class is a workaround. I want to actually clear it.

Similar Threads

  1. Class is public, should be declared in a file
    By goldhouse in forum New To Java
    Replies: 7
    Last Post: 05-10-2012, 10:17 AM
  2. why we use public access modifier?
    By vichet in forum New To Java
    Replies: 1
    Last Post: 04-04-2008, 08:04 AM
  3. Public Holidays (Australia)
    By oranjeBoven in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 09:14 AM
  4. Public class variable
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 10:58 AM
  5. public method
    By dirtycash in forum New To Java
    Replies: 4
    Last Post: 11-21-2007, 08:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •