Initializing a two-dimensional array - Java Language Basics

Java examples for Language Basics:Array

Introduction

Here's an example that initializes the sales array:

public class Main {

  public static void main(String[] args) {

    double[][] sales = { { 2.0, 2.0, 3.0, 3.0 }, // 2001
                         { 2.0, 2.0, 3.0, 2.0 }, // 2002
                         { 4.0, 3.0, 9.0, 6.0 }, // 2003
                         { 9.0, 7.0, 4.0, 3.0 }, // 2004
                         { 1.0, 2.0, 9.0, 4.0 } }; // 2005
  }

}

Related Tutorials