Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually , l have installed notepad ++ in Windows 10. And l was also successful in running my first java program in notepad ++ - "hello world". But one problem is there and this problem also occurred while running java in cmd. Even though l run my successful program in notepad  and notepad ++. But when l type this in notepad- class rudra {
                           public static void main (String [] args){
  int marks= 18; 
 System. out.println ("marks"); 
Then output comes marks but it should be 18. Why it comes so and the same problem occurred while running java in cmd also. Please help me 

What I have tried:

I am successfully able to run java programs in cmd and notepad ++ but that one isn't working.
Updated 13-Jul-21 0:35am

1 solution

Because that is exactly what you told it to do:
System.out.println ("marks");
prints a literal string: the word marks not the variable of the same name - in the same way that this code:
System.out.println ("Hello World");
prints the string Hello World
To print the variable's content, remove the double quotes:
System.out.println (marks);
Share this answer
[no name] 13-Jul-21 5:38am    
Thank you so much. That's why l love codeproject. Once again thanks
OriginalGriff 13-Jul-21 5:43am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900