473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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.


package com.company;

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, 205 views)
File Type: jpg NoRightSolution.jpg (70.7 KB, 165 views)
Dec 29 '18 #1
2 3758
Luuk
1,047 Expert 1GB
It seems yo do not understand the error:
"Error(3,8): class Main is public should be declared in a file named Main.java"

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 'Main.java' (of change line #3 to 'public class xyz', but than you will have to rename the file to xyz.java. 😉
Jan 1 '19 #2
Ishan Shah
47 32bit
The name of the public class must same as the name of the .java file in which it is placed like
Expand|Select|Wrap|Line Numbers
  1. public class Demo{}
must be placed in the Demo.java file. so either
  • Rename your file from Main.java to Demo.java
  • Rename the class from
    Expand|Select|Wrap|Line Numbers
    1. public class Demo { 
    to
    Expand|Select|Wrap|Line Numbers
    1.  public class Main {
Feb 25 '21 #3

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

Similar topics

7
by: Gapingwound | last post by:
I have one page that is not validating XHTML1 STRICT properly, but the validator at w3c is showing an error for something that is not in my page. Here's the error: 1. Line 72, column 160:...
2
by: Helen | last post by:
I've written a web control that allows you to hide certain bits of your page when the specified selectbox has a certain value. It's a simple enough bit of logic, but I got sick of coding it again...
8
by: renu434 | last post by:
Is there something that I can do in C and not in C++?
12
by: Virtual_X | last post by:
void st(const char *a) { cout << a; delete(a); } int main () { char foo= "CPP";
9
by: kimiraikkonen | last post by:
Hello experts, That's very very simple question but i wonder if you can help: I have form1 and a button which brings user to form2 when button is clicked, and i have a web-browser (.net 2.0...
2
by: =?Utf-8?B?bWVtb2lyaQ==?= | last post by:
So I accidently removed something that said windows. I don't know if it was vital or not but it said just "Windows Installer." I don't know what it is, but it's gone. I did this because my...
6
by: sartemieff | last post by:
I am using MS Access 2007 on an XP platform. I have forms (split and single) with listboxes. If a listbox is bound to a field that can contain a null, I would like the listbox to include a blank...
2
by: JSLyndon | last post by:
I want to be able to store my code for a program in a text file or store it as a string in a variable and use a function to execute that code. If anyone knows a way to do this or something similar it...
1
jhardman
by: jhardman | last post by:
I'm a bit rusty on web management, excuse me for silly question. I have a customer with unusual security who required me to deploy a separate web site in IIS because the standard user for the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.