• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

what exactly is -Toplevel class

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 Question ,i have doubt is ..
can we have more than 1 top level (noninner) classes in 1 source file.
Answer is Yes.
Explaination:As many,But only with as public and classnamefilename

I thought ,top level means -top most class(public and with samename as filename.I googled for it,It was same.

This qestion is from javaranchs, round up section itself.
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucky

By Java Language Specification:

A top level class is a class that is not a nested class.


Note that we can have more than one top level class within a file, but
only one could be declared as public. In this case the the file's name will match with the public class's name.
If there's no public class, you can give any name to your file.
Exemple:

Myclass and MyOtherclass are two top level classes.

Hope it help.
 
rubbery bacon. rubbery tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic