MSc-Y1-S2-W8-Java-Lab
for (int i = 0; i < 5; i++) {
System.out.println(i);
}
String[] cars;
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
int[] myNum = {10, 20, 30, 40};
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars[0]);
// Outputs Volvo
cars[0] = "Opel";
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars[0] = "Opel";
System.out.println(cars[0]);
// Now outputs Opel instead of Volvo
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length);
// Outputs 4
public class Card {
// suit
// value
public static void getCards(){
String[] suits = {"Hearts", "Diamonds", "Spades", "Clubs"};
String[] values = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
for (String suit : suits) {
for (String value : values) {
System.out.println(suit + value);
}
}
}
public static void main(String[] args){
getCards();
}
}
AHearts
2Hearts
3Hearts
4Hearts
5Hearts
6Hearts
7Hearts
8Hearts
9Hearts
10Hearts
JHearts
QHearts
KHearts
ADiamonds
2Diamonds
3Diamonds
4Diamonds
5Diamonds
6Diamonds
7Diamonds
8Diamonds
9Diamonds
10Diamonds
JDiamonds
QDiamonds
KDiamonds
ASpades
2Spades
3Spades
4Spades
5Spades
6Spades
7Spades
8Spades
9Spades
10Spades
JSpades
QSpades
KSpades
AClubs
2Clubs
3Clubs
4Clubs
5Clubs
6Clubs
7Clubs
8Clubs
9Clubs
10Clubs
JClubs
QClubs
KClubs
- Lab help