Skip to content

Commit 32b7c6c

Browse files
updated
1 parent 9146a02 commit 32b7c6c

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.Scanner;
2+
3+
public class inputStringArray {
4+
5+
public static void main(String[] args) {
6+
Scanner input = new Scanner(System.in);
7+
System.out.println("Welcome to String Module");
8+
System.out.println("Enter the array length : ");
9+
int stringArrayLength = input.nextInt();
10+
input.nextLine();
11+
12+
// Array Method
13+
String[] array = new String[stringArrayLength];
14+
15+
// String Builder
16+
StringBuilder myString = new StringBuilder(" ");
17+
18+
for(int i = 0; i < stringArrayLength; i++){
19+
System.out.println("Enter the String " + (i + 1)+ " Value : ");
20+
String userInput = input.nextLine();
21+
array[i] = userInput;
22+
myString.append(userInput).append(" ");
23+
}
24+
25+
System.out.println("\nStored Array");
26+
for(String str : array){
27+
System.out.print(str + " " );
28+
}
29+
30+
31+
System.out.println("\nString Builder ");
32+
System.out.println(myString);
33+
34+
input.close();
35+
36+
}
37+
38+
39+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
// Question - Create an object with final field and a constructor to initialize them.
3+
4+
public class objConstructorWithFinal {
5+
final String company;
6+
final String model;
7+
final String color;
8+
final int wheel;
9+
final String fuelType;
10+
11+
public objConstructorWithFinal(String company, String model, String color, int wheel, String fuelType) {
12+
this.company = company;
13+
this.model = model;
14+
this.color = color;
15+
this.wheel = wheel;
16+
this.fuelType = fuelType;
17+
}
18+
19+
@Override
20+
public String toString() {
21+
StringBuffer objToString = new StringBuffer();
22+
objToString.append("Company").append(" ").append(company);
23+
objToString.append("model").append(" ").append(model);
24+
25+
return objToString.toString();
26+
}
27+
28+
29+
public static void main(String[] args) {
30+
objConstructorWithFinal safari = new objConstructorWithFinal("Tata", "XUV01", "Black", 4, "Desel");
31+
32+
33+
}
34+
35+
36+
37+
38+
39+
40+
41+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package web.login;
2+
3+
public class abc {
4+
5+
public abc(){
6+
7+
}
8+
public static void main(String[] args) {
9+
web.payment.abc loginRef = new web.payment.abc();
10+
}
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package web.payment;
2+
3+
public class abc {
4+
5+
public abc(){
6+
7+
}
8+
9+
public static void main(String[] args) {
10+
web.payment.abc PaymentRef = new web.payment.abc();
11+
}
12+
}

0 commit comments

Comments
 (0)