소프트웨어 개발 165

InputStream OutputStream에 관련

public static void main(String[] args) { //왜 io프로그래밍 순서가 중요하냐! close가 중요하기 때문이다. //현재 시간을 long으로 변환 long start = System.currentTimeMillis(); //첫번째는 io관련 객체를 선언함 InputStream in = null; OutputStream out = null; try{ //InputStream 이나 OutputStream의 자손중에서 주인공의 인스턴스가 나온다. //근데 1바이트씩 읽고 1바이트씩 쓰는건 오래걸린다. /*in = new FileInputStream("c:/temp/SDSProxy.exe"); out = new FileOutputStream("c:/temp/sdspp.exe");..

main에서 일반함수를 쓰지 못하는 경우는 왜

public class HelloWorld { public static void main(String[] args) { HelloWorld m = new HelloWorld(); m.onSum(); } public void onSum() { System.out.println("a"); } } d왜 메인함수에서 static이 아닌놈은 바로 못쓰나?위와같이 하면 쓸수있다. static에는 메모리에 먼저 불러오게 되는데, 그 static에서 다른 일반함수를 쓰려면 메모리에 없는 함수를 접근하게 되어서 못한다는 것이다. 따라서 위와같이 스스로를 호출해서 객체생성을 하면 쓸수는 있기는 하다. 그렇지만, 굳이 쓰려면 그냥 public void static onSum()이러한 식으로 static을 만들어줘서 stat..