I am very new to java and coding altogether, and I haven’t figured out how to create a new file for my client class.
This is my error:
class TestRectangle is public, should be declared in a file named TestRectangle.java
public class TestRectangle {
Here’s my first class:
public class Rectangle1 {
Here’s where the error occurs:
public class TestRectangle {
public static void main(String[] args) {
Java requires that you only have one public class per a file. you have two options, either make two seperate files called Rectangle1.java and TestRectangle1.java or make your Rectangle1 with default access modifier and name your file as TestRectangle.java
Option1:
put the Rectange1 in a seperate file (Rectangle1.java) from TestRectangle
now, make a seperate file called (TestRectangle.java)
Option2:
Save this file as TestRectangle.java