
1. FirstServlet.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class FirstServlet extends HttpServlet { @Override public void init() throws ServletException{ System.out.println("메시지 호출"); } @Override public void doGet(HttpServletReque..
ArrayList The ArrayList class is a resizable array, which can be found in the java.util package. Add Items The ArrayList class has many useful methods. To add elements to the ArrayList, use the add() method: import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList people = new ArrayList(); people.add("Mom"); people.add("Dad"); people.add("Sister"); Syste..
Java Switch Statements Instead of writing many if..elsestatements, you can use the switch statement. The switch statement selects one of many code blocks to be executed. Syntax switch(expression){ case x: //code block case y: //code block break; default: //code block } This is how it works? The switch expression is evaluated once. The value of the expression is compared with the values of each c..
For any given character, I need to check if it is a vowel or consonant. Example Input : char = 'r' Output : Constant Input : char = 'e' Output : Vowel I will check if the stated character corresponds to any of the five vowels. And if it matches, “Vowel” is printed, else “Consonant” is printed. Step.1 문제 정의 (Define the problem) 알파벳이 자음이라면 ‘Consonant’ 출력 모음이라면 ‘Vowel’ 출력 Step.2 브레인스토밍 (Brainstorm)..
Whenever we are writing our classes we have to provide some information about our classes to the JVM like whether this class can be accessible from anywhere or not. whether cild class creation is possible or not, whether object creation is possible or not etc. we can specify this information by using an appropriate keyword in java called access modifiers. So access modifiers are used to set the ..
Vector Class in Java package twoOct; import java.util.Vector; public class vectorTest { public static void main(String[] args) { //Size of the Vector int n = 5; //Declaring the Vector with //initial size n Vector v = new Vector(n); //Appending new elements at the end of the vector for (int i = 1; i

Overview I have created a simple calculator program in Java that can perform basic operations like addition, subtraction, multiplication, and division. These operations are performed using a switch case statement in Java. 자바로 간단한 계산기 프로그램을 만들었다. 덧셈, 뺄셈, 곱하기, 나누기와 같은 기본 연산을 수행할 수 있다. 이 연산은 자바의 switch case문으로 구현된다. Program Description The user should input two numbers. After that the program will ..
The scanner class consists next() and nextLin() methods. next() Method: The next() method in java is present in the Scanner class and is used to get the input from the user. In order to use this method, a Scanner object needs to be created. This method can read the input only until a space (" ") is encountered. In other words, it finds and returns the next complete token from the scanner. Exampl..

숫자 만들기 게임 GUI를 구현하는 걸 배우고, 더 공부가 필요할 것 같아 정리해 봤다. 영어가 더 편해서 영어로 정리를 하겠다. Java Swing class Hierarchy Diagram Swing Swing in Java is a GUI toolkit that includes the GUI components. Swing provides a rich set of widgets and packages to make sophisticated GUI components for Java applications. Swing is a part of Java Foundation Classes(JFC), which is an API for Java GUI programing that provide GUI. Th..
// 1.Class Declaration; // The code defines a class named 'RandomGame', which contains methods and variables // to implement the number guessing game. public class RandomGame { // 2. Instance Variables; // 'answer' This is an instance variable that will store the correct answer to the guessing game. It's initially set to -1. // 사용자가 입력하는 변수는 반드시 전역변수여야 한다. // 'sc' This is an instance of the 'Sca..