By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

Error (3, 8, 13, 44); Java; IntelliJ

P: 1
Hello, tech people,

I'm newly appeared at the software stage and I don't know more than I know. So, please bare with me and give me some clear guidelines.

I'm trying to code some simple solution of one of my first tasks in Java and I can't find my mistake here. The main reason for writing this code is that I want to print my names with the count of its letters.


public class Main {

public static void main(String[] args) {
// write your code here

String meFirstName = "Smarty";
String meLastName = "Trousers";
String meFullName = meFirstName + " " + meLastName;
int letters = meFullName.length();
System.out.println("My fullname is " + meFullname + ".");
System.out.println("My name has" + " " + letters + " " + "letters.");

Thank you!
Attached Images
File Type: jpg Dunno if there has a problem Strings.jpg (100.6 KB, 42 views)
File Type: jpg NoRightSolution.jpg (70.7 KB, 39 views)
Dec 29 '18 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,035
It seems yo do not understand the error:
"Error(3,8): class Main is public should be declared in a file named"

The "(3,8)" says the error in on line #3 somewhere near character 8.
and for the rest:
The main class ('Main') seems to be public, which means you have to name the file '' (of change line #3 to 'public class xyz', but than you will have to rename the file to 😉
Jan 1 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.