paintComponent(page), Reverse digit, and Astericks triangle outputter question
Hi, I have three questions from my book "Java Software Solutions". Great book. Any help greatly appreciated! Thank you. Derek
I don't know what "page" does in the code snippet
public void paintComponent(Graphics page);
super.paintComponent (page); //where super is a reference to Jpanel I think.
page 253 //code to reverse a number input by the user
here is the snippet
The book explains it briefly but I still don't understand.
int reverse = 0;
lastDigit = number % 10; Supposedly this outputs the last digit of the number
reverse = (reverse * 10) + lastDigit;// if reverse is 0, doesn't this output zero?
number = number / 10;//I don't understand this either
This is from page 258.
It prints out a triangle of asterisks
public class Stars
public static void main (String args)
final int MAX_ROWS = 10;
for (int row = 1; row <= MAX_ROWS; row++)//this runs 10 times
for (int star = 1; star <= row; star++)// shouldn't this only output one star per row? How does it increase per row?