0

Below is my code so far. I know there is something really really trivial that I am missing. I am a beginner C++ programmer as well but still do not have much experience in that language either.

I just want this to print out if I have made the mark or not. Next I will ask for an input from the command prompt and respond accordingly. Right now the command prompt opens when I click run and that is it... No lines printed! Also there are no errors...

public class CheckPassFail {
 public static void main(CheckPassFail[] args){
 int mark=88;
 System.out.println("The mark is " + mark);
 if(mark >= 50){
 System.out.println("You Passed!");
 } 
 else{
 System.out.println("You Failed!");
 }
 }
}
Chris Mantle
6,6933 gold badges37 silver badges48 bronze badges
asked May 13, 2014 at 16:21
2
  • 2
    public static void main(String[] args) Main must have this signature which requires a String, not your custom object (you can change the variable name args to anything however). Also, see the other allowed signature from assylias's answer. Commented May 13, 2014 at 16:24
  • Change the arguments of your main to String[] args. Commented May 13, 2014 at 16:25

2 Answers 2

3

The signature of main has to be one of:

public static void main(String[] args)
public static void main(String... args)

See also: https://stackoverflow.com/a/18194838/829571

answered May 13, 2014 at 16:24
Sign up to request clarification or add additional context in comments.

Comments

2

public static void main expects its arguments to be of type String:

public static void main(String[] args)

Should fix your problem.

answered May 13, 2014 at 16:24

1 Comment

Its not of type String its of type String[]

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.