charArray을 사용한 간단한 예제입니다.

 

JAVA 의 자료형중 하나인 charArray 를 활용한 간단한 예제입니다.

 

*** 원문

 

// charArray 선언 및 값 대입
char[] charArray = new char[]{'J','a','v','a'};

"VcharArray.java"

/*
* To convert char array to String in Java, use
* String(Char[] ch) constructor of Java String class.
*/

 

 

 

 

*** 소스

 

package com.redjava.java.variable;

public class VcharArray {
 
 public static void main(String args[]){

        //char array
        char[] charArray = new char[]{'J','a','v','a'};


        /*
         * To convert char array to String in Java, use
         * String(Char[] ch) constructor of Java String class.
         */

        String str = new String(charArray);
        System.out.println("Char array converted to String: " + str);


 }


}

 

 

*** 결과

 

Char array converted to String: Java

 

 


블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

 

변수형 double을 사용한 간단한 예제입니다.

 

JAVA 의 자료형중 하나인 double 형을 활용하는 간단한 예제 입니다.

 

*** 원문

 

// double 선언 및 값 대입
double d = 1232.44;

Vdouble.java

/*
* double is 64 bit double precision type and used when fractional precision
* calculation is required.
*
* Declare double varibale as below
* 
* double = ;
* 
* here assigning default value is optional.
*/

 

 

 

*** 소스

 

package com.redjava.java.variable;

public class Vdouble {
 
 public static void main(String[] args) {

  double d = 1232.44;
        System.out.println("Value of double variable d is :" + d);              
 }

}

 

*** 결과

 

Value of double variable d is :1232.44

 

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

 

변수형 float을 사용한 간단한 예제입니다.

 

JAVA의 자료형중 하나인 float 형을 활용하는 간단한 예제 입니다.

 

*** 원문

 

// float 선언 및 값 대입
float f = 10.4f;

Vfloat.java


/*
* float is 32 bit single precision type and used when fractional precision 
* calculation is required. 
* 
* Declare float varibale as below 
* 
* float = ;
* here assigning default value is optional.
*/

 

 

 

*** 소스

 

package com.redjava.java.variable;

public class Vfloat {
 
 public static void main(String[] args) {
  
     float f = 10.4f;
        System.out.println("Value of float variable f is :" + f);   
  
 }

}

 

*** 결과

 

Value of float variable f is :10.4

 

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

 

변수형 int을 사용한 간단한 예제입니다.

 

 

JAVA의 자료형중 하나인 int 를 활용하는 간단한 예제 입니다.

 

*** 원문

 

/*
* int is 32 bit signed type ranges from ?2,147,483,648 
* to 2,147,483,647. int is also most commonly used integer 
* type in Java.
* Declare int varibale as below
* 
* int = 
;
*
 
* here assigning default value is optional.
*/

 

 

 

*** 소스

 

package com.redjava.java.variable;

public class Vint {

  public static void main(String[] args) {

  

          int i = 0;
          int j = 100;


          System.out.println("Value of int variable i is :" + i);
          System.out.println("Value of int variable j is :" + j);


 }
}

 

 

*** 결과

 

Value of int variable i is :0
Value of int variable j is :100

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

 

변수형 long을 사용한 간단한 예제입니다.

 

Java 의 자료형 중 하나인 long 을 활용한 간단한 예제 입니다.

 

*** 원문

Vlong.java

/*
* long is 64 bit signed type and used when int is not large
* enough to hold the value.
*
* Declare long varibale as below
*
* long = ;
*
* here assigning default value is optional.
*/

 

 

 

 

*** 소스

package com.redjava.java.variable;

import java.util.Date;

public class Vlong {
 
 public static void main(String[] args) {

    long timeInMilliseconds = new Date().getTime();
       System.out.println("Time in milliseconds is : " + timeInMilliseconds);   
  
 }

}

 

 

*** 결과

Time in milliseconds is : 1353309685380

 

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

 

변수형 short을 사용한 간단한 예제입니다.

 

Java 의 자료형 중 하나인 short 를 활용한 간단한 예제 입니다.

 

*** 원문

Vshort.java

* short is 16 bit signed type ranges from ?32,768 to 32,767.

*
* Declare short varibale as below
* 
* short = ;
* 
* here assigning default value is optional.
*/

 

 

 

 

*** 소스

package com.redjava.java.variable;

public class Vshort {
 
 
 public static void main(String[] args) {
   short s1 = 50;
      short s2 = 42;

   System.out.println("Value of short variable b1 is :" + s1);
   System.out.println("Value of short variable b1 is :" + s2);
  
 }

}

*** 결과

Value of short variable b1 is :50
Value of short variable b1 is :42

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,

변수형 boolean을 사용한 간단한 예제입니다.

 

 

Java  의 자료형중 하나인 boolean 을 사용하는 간단한 예제 입니다.

 

*** 원본설명

 

Vboolean.java


/*
* boolean is simple Java type which can have only of two values; true or false.

* All rational expressions retrun this type of value. 
*
* Declare boolean varibale as below
* 
* boolean = ;
* 
* here assigning default value is optional.
*/

 

*** 소스

 

package com.redjava.java.variable;

public class Vboolean {
 
    public static void main(String[] args) {

 

        boolean b1 = true;
        boolean b2 = false;
       
        boolean b3 = (10 > 2)? true:false;

        System.out.println("Value of boolean variable b1 is :" + b1);
        System.out.println("Value of boolean variable b2 is :" + b2);
        System.out.println("Value of boolean variable b3 is :" + b3);           


    } 

}

 

 

*** 결과

Value of boolean variable b1 is :true
Value of boolean variable b2 is :false
Value of boolean variable b3 is :true

 

 

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,