1) Интерфейс (код) class TestFrame
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class TestFrame {
public static void createGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Test frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Test label");
frame.getContentPane().add(label);
frame.setPreferredSize(new Dimension(200, 100));
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createGUI();
}
});
}
}
2) код (консоль) class gg
import java.util.Scanner;
public class gg {
public static void main (String[] args) {
System.out.println("Введите слово");
Scanner scanner = new Scanner(System.in);
String a = scanner.nextLine();
System.out.print("В слове " + a + " " + a.length() + " БУКВЫ ");
}
}
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class TestFrame {
public static void createGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Test frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Test label");
frame.getContentPane().add(label);
frame.setPreferredSize(new Dimension(200, 100));
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createGUI();
}
});
}
}
2) код (консоль) class gg
import java.util.Scanner;
public class gg {
public static void main (String[] args) {
System.out.println("Введите слово");
Scanner scanner = new Scanner(System.in);
String a = scanner.nextLine();
System.out.print("В слове " + a + " " + a.length() + " БУКВЫ ");
}
}