Yao Lirong's Blog

Java Quick Guide

2021/09/10

Basics

  • Basic File Structure:

    1
    2
    3
    4
    5
    public class <SameAsFileName> {
    public static void main(String args[]){

    }
    }
  • Typecasting: int a = (int) pow(2,5);

  • Binary: reference to formatting,

    1
    2
    3
    4
    5
    6
    7
    int i = 0b10101010; // give binary value
    System.out.println(Integer.toBinaryString(x)); // print binary
    Integer.parseUnsignedInt("10101010", 2); //input binary

    // print with padding
    String.format(formatPattern, Integer.toBinaryString(data)).replace(' ', '0');
    String formatPattern = "%" + maximumExpectedSize + "s";
  • good

String

CATALOG
  1. 1. Basics
  2. 2. String