잘 이해도 안되는 부분이 있어서 나중에 볼려고 올림
import java.util.*;
class ArgDelivery1
//값에 의한 전달
/*
{
public static void main(String[] args)
{
int a=2, b=3, c=6, d=10, e=5, f=7;
Disp(a, b, c, d, e, f);
}
public static void Disp(int i, int j, int k, int l, int m, int n){
System.out.println(i + "," + j + "," + k + "," + l + "," + m + "," + n + ",");
}
}
*/
//주소에 의한 전달
/*
{
public static void main(String[] args)
{
int[] arr = {2, 3, 6, 10, 5, 7};
Disp(arr);
}
public static void Disp(int[] arr1){
for(int i=0; i<arr1.length; i++)
System.out.print(arr1[i] + ",");
}
}
*/
//주소에 의한 전달 2차원 배열
/*
{
public static void main(String[] args)
{
int[][] arr ={ {2, 3}, {6, 10}, {5, 7}};
Disp(arr);
}
public static void Disp(int[][] arr1){
for(int i=0; i<arr1.length; i++)
for(int j=0; j<arr1[i].length; j++)
System.out.print(arr1[i][j] + ",");
}
}
*/
//데이터의 자료형이 다를 경우
/*
{
public static void main(String[] args)
{
String name = "홍길동";
int age = 24;
double pay = 1000000;
boolean marry = false;
Disp(name, age, pay, marry);
}
public static void Disp(String n, int a, double p, boolean m){
System.out.print(n + "," + a + "," + p + "," + m);
}
}
*/
//클래스로
/*
{
public static void main(String[] args)
{
ArgDemo ad = new ArgDemo("홍길동",24,1000000,false);
ad.Disp();
}
}
class ArgDemo
{
String name;
int age;
double pay;
boolean marry;
ArgDemo(String name, int age, double pay, boolean marry)
{
this.name = name;
this.age = age;
this.pay = pay;
this.marry = marry;
}
public void Disp(){
System.out.print(name + "," + age + "," + pay + "," + marry);
}
}
*/
//Collection으로
/*
{
public static void main(String[] args)
{
Vector vec = new Vector();
vec.add("홍길동");
vec.add(24);
vec.add(1000000);
vec.add(false);
Disp(vec);
}
public static void Disp(Vector vec){
for(int i=0; i<vec.size(); i++)
System.out.print(vec.get(i) + ",");
}
}
*/
//클래스와 Collection을 복합적으로
{
public static void main(String[] args)
{
ArgDemo ar = new ArgDemo();
Vector vec = new Vector();
vec.addElement(ar);
Disp(vec);
}
public static void Disp(Vector vec1){
ArgDemo ar = (ArgDemo)vec1.elementAt(0);
System.out.print(ar.name + "," + ar.age + "," + ar.pay + "," + ar.marry);
}
}
class ArgDemo
{
String name= "홍길동";
int age = 24;
double pay = 1000000;
boolean marry = false;
}
ChatGPT, 블록체인, 자바, 맥북, 인터넷, 컴퓨터 정보를 공유합니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!