---
title: "Is it possible to have multiple public classes in Java ?"  
description: "Is it possible to have multiple public classes in Java ?"  
author: "Anonymous User"  
published: 2015-07-14  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/2698/is-it-possible-to-have-multiple-public-classes-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Is it possible to have multiple public classes in Java ?

As per java language specification, there can be only one public class in a file (.java) and file name should be same as public class name. If you want another class accessible in other places, you may create a separate java file.

## Answers

### Answer by Anonymous User

As per java language specification, there can be only one public class in a file (.java) and file name should be same as public class name. If you want another class accessible in other places, you may create a separate java file.


---

Original Source: https://www.mindstick.com/interview/2698/is-it-possible-to-have-multiple-public-classes-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
