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!

Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS