0% found this document useful (0 votes)
34 views

Public Class Public Static Void For: Args String Args String

The document provides code snippets for 3 Java programs that accept command line arguments. The first program outputs two strings separated by a tab. The second program outputs a welcome message for each string argument. The third program accepts two integers as arguments, sums them, and prints the result.

Uploaded by

Gayu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Public Class Public Static Void For: Args String Args String

The document provides code snippets for 3 Java programs that accept command line arguments. The first program outputs two strings separated by a tab. The second program outputs a welcome message for each string argument. The third program accepts two integers as arguments, sums them, and prints the result.

Uploaded by

Gayu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Write a Program that accepts two Strings as command line arguments and generate the output
in a specific way as given below.

public class Sample1

public static void main( String args[])

System.out.println(args[0]+"\t"+"technologies");

System.out.println(args[1]);

2. Write a Program to accept a String as a Command line argument and the program should print
a Welcome message.

public class Sample2 {


public static void main(String[] args)
{
for(String string:args)
{
System.out.println("Welcome"+string);
}
}

3. Write a Program to accept two integers through the command line argument and print the sum
of the two numbers

public class Sample3 {


public static void main(String args[])
{
int x,y,s;
x= Integer.parseInt(args[0]);
y= Integer.parseInt(args[1]);
s= x+ y;
System.out.println("Sum of\t"+ x +"\tand\t"+ y +"\tis\t" +s);
}
}

You might also like