How to change value of array element in 2D arrays?

后端 未结 3 962
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 05:54

Let\'s say I got this map that prints out:

00000
00000
00000

How do I change the element in [0][0] into an X?

In other words, how t

3条回答
  •  抹茶落季
    2021-01-17 06:21

    Run this:

    import java.util.*;
    import java.lang.*;
    
    class Main
    {
            public static void main (String[] args) throws java.lang.Exception
            {
                    String[][] array = {{"0","0","0"},{"0","0","0"},{"0","0","0"}};
    
                    System.out.println("Before: ");
                    printArray(array);
    
    
                    array[0][0] = "x";
                    System.out.println("After: ");
                    printArray(array);
    
            }
    
            private static void printArray(String[][] array){
                    for(int i=0; i

    Or go here: http://ideone.com/2DQC1

提交回复
热议问题