전체 글 (138) 반응형 썸네일형 리스트형 ByteShortIntLong Max/Min package com.company; public class Main { public static void main(String[] args) { int myValue = 10000; int myMinIntValue = Integer.MIN_VALUE; int myMaxIntValue = Integer.MAX_VALUE; System.out.println("Integer Minimum Value = " + myMinIntValue); System.out.println("Integer Maximum Value = " + myMaxIntValue); System.out.println("Busted Max value = " + (myMaxIntValue+ 1)); System.out.println("Buste.. Generics Class 기본예시/ Team- player abstract class (player) - basic class (Team)/Generics class - main | sub class 3개 (basketball player, soccer player..등) 해당player(basketball player)에 맞는 각 team class(basketball player team)만드는 대신 Team class 자체를 Generics class로 정의하여 각 team class 만들어야하는 거 방지. Abstrac class- Player package com.timbuchalka; /** * Created by dev on 17/10/2015. */ public abstract class Player { private String name; pub.. Program to Illustrate Enhanced For Loop Program: class EnhancedForLoop { public static void main(String[] args) { int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; System.out.println("Enhanced for loop:"); for (int t: primes) { System.out.println(t); } } } Output: Enhanced for loop: 2 3 5 7 11 13 17 19 23 29 Program to Print Multiplication Table Program: import java.util.Scanner; class MultiplicationTable{ public static void main(String args[]){ int n, c; System.out.println("Enter an integer to print it's multiplication table: "); Scanner in = new Scanner(System.in); n = in.nextInt(); System.out.println("Multiplication table of " + n); for (c = 1; c Program to know the functionality of Static Block Program: class StaticBlock { public static void main(String[] args) { System.out.println("Main method is executed."); } static { System.out.println("Static block is executed before main method."); } } Output: Static block is executed before main method. Main method is executed. find odd or even Program: import java.util.Scanner; class OddOrEven { public static void main(String args[]) { int x; System.out.println("Enter an integer to check if it is odd or even"); Scanner in = new Scanner(System.in); x = in.nextInt(); if (x % 2 == 0) System.out.println("The number is even."); else System.out.println("The number is odd."); } } Output: Enter an integer to check if it is odd or even 5 The n.. polymorphism 다형성 코드 비교 diffmerge 코드 txt 비교. 이전 1 ··· 12 13 14 15 16 17 18 다음