Answer to Question #246346 in Java | JSP | JSF for Dodong

Question #246346
Have you ever answered a test question that tells you to enumerate a series of things, but the answer must be in a sentence? Quite tiring to write those things separated by commas and a single space, isn't it?

Then let's try coding it instead!
1
Expert's answer
2021-10-04T23:10:28-0400
import java.util.*; 
public class Main
{
	public static void main(String[] args) {
		List<String> ws = new ArrayList<>();
        ws.add("c++");
        ws.add("java");
        ws.add("c");
        ws.add("python");
        ws.add("c#");
        String sentence = "";
        
        for (String word : ws)
        {
            sentence = sentence + word + " , ";
        }
        System.out.println(sentence);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS