How to Structure Java String Code in a Static Main Method?

  • Context: Comp Sci 
  • Thread starter Thread starter anyonebutangel
  • Start date Start date
  • Tags Tags
    Code Java String
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
anyonebutangel
Messages
40
Reaction score
5
Homework Statement
I want to write a program in java that takes a sentence as an input and displays each word separately in a new line .I came up with this .But the compiler is displaying an error and i can't make out where i made a mistake.
Relevant Equations
no idea what equations
it's written in Java and compiled with JDK1.5
here the class name is test153 sent is the sentence entered l is the length of the sentence w is the variable storing each word temporarily before printing.
 

Attachments

  • IMG-20200904-WA0048.jpg
    IMG-20200904-WA0048.jpg
    50.5 KB · Views: 206
on Phys.org
Look for a hello world example in java and you’ll see they use a static main method To contain their code.

Basically you need to place your code in a static main method.
 
jedishrfu said:
Look for a hello world example in java and you’ll see they use a static main method To contain their code.

Basically you need to place your code in a static main method.
yeah.done thanks for help.
 
  • Like
Likes   Reactions: jedishrfu