Skip to content
Advertisement

String[] no longer working in visual code studio

I updated Visual Studio Code, created a new file and messed around with Java and something broke. Can someone please help me out?

import java.util.*;
public class test 
{

  public static void main(String[] args) {
   
    String[] test = ("1,2,3,4,5");

    for (String i : test) {
    System.out.print(test);
      {
  }

}

This is usually how I input my code for my stuff but today I got an error:

“Cannot Resolve String[] to String”

This has never happened to me before and I do not know what to do. I would appreciate if you can help me.

Advertisement

Answer

Based on the code you provided, I guess this is what you want

public class test {

    public static void main(String[] args) {

    String[] test = {"1", "2", "3", "4", "5"};

        for (String i : test) {
            System.out.print(i);
        }

    }

}

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement