1. 형변환이란?

  - 특정 자료형의 값을 다른 자료형에 대입하는 방식


2. 형변환의 종류

 (1) 자동 형변환(Promotion) : 큰 자료형에 작은 자료형의 값을 대입하는 경우

      Example : byte b = 10;

                     int i     = b;


 (2) 강제 형변환(Casting) : 작은 자료형에 큰 자료형을 대입하는 경우

      Example : int i = 10;

                     byte b = (byte)i;


3. 자료형 변환 예제

 (1) short s = 10; char b = a;

      -> Error발생, casting임. short 형은 -32,768 ~ 32,767, char는 0 ~ 65535 인데,

          Promotion이 되려면 포함되어야 하나 범위가 맞지 않는다.

          char b = (char)a; 로 되어야함.

  (2) long lo = 12L; float fl = lo;

       -> Error발생하지 않음, 기본적으로 실수는 정수보다 큼!       

'프로그래밍 > Java' 카테고리의 다른 글

[Java] 연산자-2  (0) 2016.04.08
[Java] 연산자-1  (0) 2016.04.05
[Java] Literals  (0) 2016.04.03
[Java] 자료형의 Default Value  (0) 2016.04.03
[Java] 자료형  (0) 2016.03.29

이걸 왜 샀지 하는 순간 Raspberry Pi 2 Model B를 덜컥 아마존에서 구매했습니다.

이걸 가지로 잘 놀아보도록 하겠습니다.


제목 : 유시민의 글쓰기 특강

내용 : 지난시절 정치인으로 알고 있었던 유시민님의 글쓰기 기술 공개

느낌 : 항상 우리나라 정치인중 가장 논리적으로 이야기를 한다고 생각하고 

         있었는데, 다시한번 논리력과 글쓰기 실력을 볼수 있었습니다.

         블로그에 쓰는 글조차 다시 한번 보게 만드는 글쓰는 기술.

         중고등학교때 보았으면 더 좋았을 지침서!

         한번에 다 읽게 만드는 집중력 유도 글쓰기!

         최근 읽었던 책중에 최고였습니다!




Literals(이후 정리할 예정입니다.)

You may have noticed that the new keyword isn't used when initializing a variable of a primitive type. Primitive types are special data types built into the language; they are not objects created from a class. A literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation. As shown below, it's possible to assign a literal to a variable of a primitive type:

boolean result = true; char capitalC = 'C'; byte b= 100; short s = 10000; int i = 100000;

Integer Literals

An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1.

Values of the integral types byteshortint, and long can be created from int literals. Values of type long that exceed the range of int can be created fromlong literals. Integer literals can be expressed by these number systems:

  • Decimal: Base 10, whose digits consists of the numbers 0 through 9; this is the number system you use every day
  • Hexadecimal: Base 16, whose digits consist of the numbers 0 through 9 and the letters A through F
  • Binary: Base 2, whose digits consists of the numbers 0 and 1 (you can create binary literals in Java SE 7 and later)

For general-purpose programming, the decimal system is likely to be the only number system you'll ever use. However, if you need to use another number system, the following example shows the correct syntax. The prefix 0x indicates hexadecimal and 0b indicates binary:

// The number 26, in decimal
int decVal = 26;
//  The number 26, in hexadecimal
int hexVal = 0x1a;
// The number 26, in binary
int binVal = 0b11010;

Floating-Point Literals

A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.

The floating point types (float and double) can also be expressed using E or e (for scientific notation), F or f (32-bit float literal) and D or d (64-bit double literal; this is the default and by convention is omitted).

double d1 = 123.4;
// same value as d1, but in scientific notation
double d2 = 1.234e2;
float f1  = 123.4f;

Character and String Literals

Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a "Unicode escape" such as '\u0108' (capital C with circumflex), or "S\u00ED Se\u00F1or" (Sí Señor in Spanish). Always use 'single quotes' for char literals and "double quotes" for String literals. Unicode escape sequences may be used elsewhere in a program (such as in field names, for example), not just in char or String literals.

The Java programming language also supports a few special escape sequences for char and String literals: \b (backspace), \t (tab), \n (line feed), \f (form feed), \r (carriage return), \" (double quote), \' (single quote), and \\ (backslash).

There's also a special null literal that can be used as a value for any reference type. null may be assigned to any variable, except variables of primitive types. There's little you can do with a null value beyond testing for its presence. Therefore, null is often used in programs as a marker to indicate that some object is unavailable.

Finally, there's also a special kind of literal called a class literal, formed by taking a type name and appending ".class"; for example, String.class. This refers to the object (of type Class) that represents the type itself.

Using Underscore Characters in Numeric Literals

In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code.

For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator.

The following example shows other ways you can use the underscore in numeric literals:

long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
float pi =  3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;

You can place underscores only between digits; you cannot place underscores in the following places:

  • At the beginning or end of a number
  • Adjacent to a decimal point in a floating point literal
  • Prior to an F or L suffix
  • In positions where a string of digits is expected

The following examples demonstrate valid and invalid underscore placements (which are highlighted) in numeric literals:

// Invalid: cannot put underscores
// adjacent to a decimal point
float pi1 = 3_.1415F;
// Invalid: cannot put underscores 
// adjacent to a decimal point
float pi2 = 3._1415F;
// Invalid: cannot put underscores 
// prior to an L suffix
long socialSecurityNumber1 = 999_99_9999_L;

// OK (decimal literal)
int x1 = 5_2;
// Invalid: cannot put underscores
// At the end of a literal
int x2 = 52_;
// OK (decimal literal)
int x3 = 5_______2;

// Invalid: cannot put underscores
// in the 0x radix prefix
int x4 = 0_x52;
// Invalid: cannot put underscores
// at the beginning of a number
int x5 = 0x_52;
// OK (hexadecimal literal)
int x6 = 0x5_2; 
// Invalid: cannot put underscores
// at the end of a number
int x7 = 0x52_;


'프로그래밍 > Java' 카테고리의 다른 글

[Java] 연산자-1  (0) 2016.04.05
[Java] 자료형의 변환  (0) 2016.04.04
[Java] 자료형의 Default Value  (0) 2016.04.03
[Java] 자료형  (0) 2016.03.29
[Java] 시작하기  (0) 2016.03.27

Java의 Default Value

Compiler에 의해 초기화 되는 값으로, 아래 표와 같이 초기화 됩니다. 하지만 컴파일러에 의한 초기값으로
의존하는것은 좋은 programming 습관이 아닙니다.

Default Values

It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally speaking, this default will be zero or null, depending on the data type. Relying on such default values, however, is generally considered bad programming style.

The following chart summarizes the default values for the above data types.


Data Type

Default Value (for fields)

byte

0

short

0

int

0

long

0L

float

0.0f

double

0.0d

char

'\u0000'

String (or any object)  

null

boolean

false

'프로그래밍 > Java' 카테고리의 다른 글

[Java] 연산자-1  (0) 2016.04.05
[Java] 자료형의 변환  (0) 2016.04.04
[Java] Literals  (0) 2016.04.03
[Java] 자료형  (0) 2016.03.29
[Java] 시작하기  (0) 2016.03.27

미국으로 이민을 결정하고, 가장 먼저 걱정되는것은 다름 아니라 "영어!!!!!" 였습니다.


한국에서 영어를 준비할 수 있는 방법을 생각해보면? 

생각나는대로 방법을 적어보았습니다.




1번, 외국인과 1:1 또는 1:다수의 영어과외



장점 : 정해진 시간을 모두 쓸 수 있다.

단점 : 가격이 어마어마 하다....



2번, 요즘 접하기 쉬운 1:1 영어학원


장점 : 시스템이 잘되어있고, 스케줄 잡기가 편하다.(선생님 선택가능)

단점 : 역시 가격이 어마어마 하다.



3번, 영어회화 학원


장점 : 원하는 시간대에 수강이 가능하다. 가격이 저렴하다.

단점 : 수업시간을 온전히 쓸 수 없다. 어떤날은 "Hello~"만 말하고 끝나기도 한다.



4번, 전화 or 화상영어


장점 : 가격이 저렴하다. 편한 시간대에 항상 가능하다.

단점 : 고작 10분 or  20분이며, 얼굴보며 회화보다는 효과가 적다.



5번, 영어회화 스터디

장점 : 여러사람들과 어울리며, 영어를 준비할 수 있다.

단점 : 비슷한 수준의 사람들과 대화를 하나, 단기적으로는 효과가 적음.


진짜 오랜만에 영주권 준비 상황에 대해서 블로그를 적게 되었습니다.

써놓은 글들도 있고, 차근차근 정리해서 올려야 겠습니다.



배경 : 영주권을 받은 후 와이프를 초청 하게 되었습니다.

카테고리 : 영주권자의 배우자의 경우는 F2A


2016년 4월 기준 문호




대략적인 예상 가능한 시점 확인 Site

http://www.myprioritydate.com/


자신의 우선일자를 입력하고, 카테고리를 선택하면 대략적인 날짜가 나온다.

예상은 예상일 뿐이니, 참고하시기만 하면 됩니다.

그래도 나름대로 십년넘는 기간동안의 data를 분석하고 예측한다.


 

'이민준비 > 미국 영주권 준비' 카테고리의 다른 글

2016년 5월 영주권 문호  (0) 2016.04.13
2015년 영주권 통계  (0) 2016.04.11
DS-260 작성법(1, System Login)  (0) 2014.01.10
I-130 청원서 승인후 해야할 일!  (0) 2014.01.09
영주권 문호란??  (0) 2014.01.08

1. 상수와 변수 그리고 자료형

  - 상수(Constant) : 항상 일정한 값을 유지하는 데이터

  - 변수(Variable) : 특정 상황에 따라 변화하는 데이터

  - 자료형 : 상수나 변수의 유동적인 데이터를 저장할 수 있는 크기를 규정하는 형태



2. 자바의 기본 자료형과 String 클래스

 1) 논리형 자료형

   (1) boolean

     - 사용 byte : 1byte, 입/출력 범위 : true or false

     - Example :

boolean b = true


  2) 정수형 자료형

   (1) byte    

     - 사용 byte : 1byte, 입/출력 범위 : -128 ~ 127

     - Example :

byte by = 123


     - Bit level 설명

     가장 상위 Bit는 부호 비트, 양 과 음을 표시함.

     아래와 같이 되기 때문에, 0,1,2,3.......127,-128,-127..........-3,-2,-1 된다.


0000 0000 = 0

0000 0001 = 1

0000 0010 = 2

......................

0111 1111 = 127

1000 0000 = -128

1000 0001 = -127

......................

1111 1110 = -2

1111 1111 = -1



   (2) char

     - 사용 byte : 2byte(unsigned data), 입/출력 범위 : 0 ~ 65,635

     - Example :

char ch = 65;(A의 ASCII 값)
char ch = 'A';(문자 형태 그대로 적음)
char ch =  \u0041;(\u는 unicode, 0041은 65의 16진수 값)

- ASCII코드에 대한 설명은 추후에 하겠습니다.


   (3) short

     - 사용 byte : 2byte, 입/출력 범위 : -32,768 ~ 32767

     - Example :

short  sh =  30,000


   (4) int

     - 사용 byte : 4byte, 입/출력 범위 : -2,147,483,648 ~ 2,147,483,647

     - Example :

int i =  40,000

     - 특이사항

        byte a, b;

        a = 10; b = 20;

        a+b = int형 30

       +연산을 하면 byte 형이 int형으로 바뀜


     - 표기법

        // The number 26, in decimal (10진수)

        int decVal = 26;

        // The number 26, in hexadecimal (16진수)

        int hexVal = 0x1a;

        // The number 26, in binary (2진수)

        int binVal = 0b11010;


   (5) long

     - 사용 byte : 8byte, 입/출력 범위 : -9,223,372,036,854,775,808 ~ 

 -9,223,372,036,854,775,807

     - Example :

long l =  12345L;

     - 특이사항

       long형의 경우 뒤에 l or L을 붙여야 함.

       'l'의 경우 1과 혼동의 경우가 있어 'L'로 적는것이 좋음


  3) 실수형 자료형

   (1) float

     - 사용 byte : 4byte, 입/출력 범위 : 1.4E^-45 ~ 3.402823E^38

     - Example :

float f =  12.34f;


   (2) double

     - 사용 byte : 8byte, 입/출력 범위 : 4.9E^-324 ~ 1.8E^308

     - Example :

double d =  12345.6789;


  4) 클래스형 자료형

   (1) String

     - 사용 byte : 4byte, 입/출력 범위 : 무한대

     - Example :

String s =   'string';

     - 특이사항

       String은 Class 이며, 자바에서는 Class의 경우 4byte임.





'프로그래밍 > Java' 카테고리의 다른 글

[Java] 연산자-1  (0) 2016.04.05
[Java] 자료형의 변환  (0) 2016.04.04
[Java] Literals  (0) 2016.04.03
[Java] 자료형의 Default Value  (0) 2016.04.03
[Java] 시작하기  (0) 2016.03.27

+ Recent posts