'Tips for creating an efficient way to populate a chess board (2D array) - Java with chess pieces

I am currently working on creating a chess game in android studio - in Java. I have a board class which contains a 2D array of tiles. Each of these tiles has the possibility (optional variable) to contain a piece. The piece class has sub classes for the different type of pieces.

I am now working on populating the board with the pieces and was wondering if there is some sort of effective way of doing this? I can run through the array with a massive switch case but that just seems dumb.

Also, later on I plan to develop an AI to play against and it would be useful to be able to easily input random board positions to test its capabilities.

Any advice?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source