+ 1

Why my code is not showing any output

Can anyone pls help me by telling me why my code is not working. https://sololearn.com/compiler-playground/cROVwNWi2jUv/?ref=app

12th Mar 2024, 10:31 AM
ShadowKid
ShadowKid - avatar
5 Answers
+ 2
Have a look at the parameters of Java's main method. https://www.javatpoint.com/java-main-method It takes a string array. Note that sololearn Java playground is not interactive; you cannot pass command line arguments.
12th Mar 2024, 10:42 AM
Lisa
Lisa - avatar
+ 2
First, you need to change the following. --public static void main(String[] args)-- String[] args is a command line argument, so the argument can only be passed at runtime. And this site, as far as I know, does not pass arguments at runtime. So you need to define a function or write variables directly. Example: public class Program { public static void main(String[] args) { //Directly String customerName="ABC"; System.out.println("Customer Name:" + customerName); //call function call("CDE",101); } public static void call(String customerName, int membershipCode){ System.out.println("Customer Name:" + customerName); System.out.println("Membership code:" + membershipCode); } }
12th Mar 2024, 10:58 AM
Shugo
Shugo - avatar
+ 1
Thank you
12th Mar 2024, 10:59 AM
ShadowKid
ShadowKid - avatar
0
I don't understand pls say in simple way
12th Mar 2024, 10:56 AM
ShadowKid
ShadowKid - avatar
0
I made a sample. You can input the customer name. https://www.sololearn.com/en/compiler-playground/cb8lUiOPjEbA
13th Mar 2024, 11:03 AM
Shugo
Shugo - avatar