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
259
Reaction score
36
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

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top