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.
 
Joined
Apr 25, 2017
Messages
247
Reaction score
31
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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top