INFO1113 - Final Exam Notes

INFO1113 × Final Exam

复习中…持续更新…(个人笔记 仅供参考T T)

Topics

Text File I / O

1. Input
Scanner

import java.util.Scanner;
Scanner sc = new Scanner(System.in); // create a scanner object

String a = sc.nextline(); // catch next line
String b = sc.next(); // catch next word
int c = sc.nextInt(); // catch next integer

② Command Line Arguments

  • If not having inputs, will raise ArrayIndexOutOfBoundsException.
String s = args[0];
int n = Integer.parseInt(args[0]);

// length of command line arguments
int length = args.length;

2. Output

System.out.println("Hello World!"); // print on the next line
System.out.print("Hello World!"); // print on the same line

3. printf formatting

  • Character: %2c
  • Integer: %5d
  • Floating-point number: %6.2f (2 digits after the decimal in a field of 6 spaces)
  • String: %10s

Notes

Static & Non-static

W1: Static modifier allows it to be accessed without the need of an object

Practice Exam

上一篇:The Best HPE2-W02 Exam Cram Ever - Pass Easily HPE2 W02 Exam


下一篇:Avail HP0-Y50 Exam Cram Curated by HP Experts