For example, say I have a simple coin flip program that display a single line of text. After running the program as a Java Project, the console would display "There are 473 heads and 527 tails." I don't mean displaying this in LogCat, but actually displaying it when using the application.
//Basic coin flip statistics program.
package com.company.practice;
import java.util.Random;
public class CoinFlip {
public static void main(String[] args){
System.out.println("Toss a coin 1000 times");
int heads = 0;
int tails = 0;
Random r = new Random();
for(int flips = 0; flips < 1000; flips++){
//Change the # after < to set amount of flips.
int side = r.nextInt(2);
if(side == 0) heads++;
else tails++;
}
System.out.println("There are " + heads + " heads and " + tails + " tails.");
}
}
How would I display the line of code at the bottom that says, "System.out.println(...)" as text in an Android Application's activity?