Java problem


Joined
Dec 26, 2019
Messages
1
Reaction score
0
So I've always wanted to learn how to code and I've decided to take it up.
-------------------------------------------------------------------
public class D {

public static void main(String[] args) {
// TODO Auto-generated method stub



}
addExlamationMark("Hello there")
public static void addExclamationMark(String s);{
System.out.println(s + "!");
}
};

-------------------------------------------------------------------
I am trying to print a line where it says my "Hello there" but adds an exclamation mark.
Like adding 2 strings together.
-----------------
Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at D.main(D.java:4)
-------------------
This is what the console tells me and i cant make it work.
Sorry for being brain dead.
 
Ad

Advertisements

Joined
Apr 25, 2017
Messages
172
Reaction score
23
You have lot of errors here.

1. You should call addExlamationMark method inside main method.
2. You named the method with two different names, one is addExlamationMark and another is addExclamationMark. I guess one is typo?

The correct code should be

Java:
public class D {

public static void main(String[] args) {
  // TODO Auto-generated method stub
  addExclamationMark("Hello there");
}

public static void addExclamationMark(String s) {
    System.out.println(s + "!");
   }
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

illegal start of type 1
Java socket programming 1
Java Animation 0
JAVA RMI PROBLEM 0
BotSavesPrincess Problem 5
Extreme beginer 12
Not able to run jar file 0
Reading a File 8

Top