
How I generate table in showMessageDialog.
E.g
3X1=3
3X2=6
3X3=9print("code sample");

Hi Friend,
Try this:
import javax.swing.*;
public class MultiplicationTable{
public static void main(String args[]){
StringBuffer buffer=new StringBuffer();
String number=JOptionPane.showInputDialog(null,"Enter number whose table is to be displayed");
int n=Integer.parseInt(number);
int result;
for (int a = 1; a <= 10; a++)
{
result = n * a;
buffer.append(n);
buffer.append(" * ");
buffer.append(a);
buffer.append(" = ");
buffer.append(result);
buffer.append("\n");
}
JOptionPane.showMessageDialog(null,buffer.toString());
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.