Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 97ea760

Browse files
Initial commit
1 parent 441bdc0 commit 97ea760

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

‎project/project.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

‎project/src/Main.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
2+
// then press Enter. You can now see whitespace characters in your code.
3+
public class Main {
4+
public static void main(String[] args) {
5+
// Press Alt+Enter with your caret at the highlighted text to see how
6+
// IntelliJ IDEA suggests fixing it.
7+
System.out.printf("Hello and welcome!");
8+
9+
// Press Shift+F10 or click the green arrow button in the gutter to run the code.
10+
for (int i = 1; i <= 5; i++) {
11+
12+
// Press Shift+F9 to start debugging your code. We have set one breakpoint
13+
// for you, but you can always add more by pressing Ctrl+F8.
14+
System.out.println("i = " + i);
15+
}
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package lk.himash;
2+
3+
import java.util.*;
4+
5+
public class Illustration_01 {
6+
public static void main(String[] args) {
7+
8+
// Write a program to find the first non-repeating number in the following array
9+
int [] arr = new int [] {5, 4, 2, 5, 3, 8, 5, 2, 1, 8};
10+
HashSet<Integer> uniqueValues = new HashSet<>();
11+
List<Integer> duplicates = new ArrayList<>();
12+
List<Integer> list = new ArrayList<>();
13+
14+
for (int j : arr) {
15+
list.add(j);
16+
if (!uniqueValues.add(j)) { // If the value added success true otherwise false
17+
duplicates.add(j);
18+
}
19+
}
20+
21+
list.removeAll(duplicates);
22+
23+
System.out.println("Initial non-duplicate value is : " + list.get(0));
24+
25+
}
26+
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package lk.himash;
2+
3+
import java.util.ArrayList;
4+
import java.util.HashSet;
5+
import java.util.List;
6+
import java.util.Set;
7+
8+
public class Illustration_02 {
9+
public static void main(String[] args) {
10+
11+
// Write a program to find the all repeating numbers & non-repeating numbers & remove duplicates in the following array
12+
int [] arr = new int [] {5, 4, 2, 5, 3, 8, 5, 2, 1, 8};
13+
List<Integer> list = new ArrayList<>();
14+
Set<Integer> nonRepeatNo = new HashSet<>();
15+
List<Integer> repeatNo = new ArrayList<>();
16+
17+
for(int i=0; i<arr.length; i++){
18+
list.add(arr[i]);
19+
if(!nonRepeatNo.add(arr[i])) {
20+
repeatNo.add(arr[i]);
21+
}
22+
}
23+
24+
list.removeAll(repeatNo);
25+
26+
System.out.println("without duplicates : " + list);
27+
System.out.println("duplicates : " + repeatNo);
28+
System.out.println("non duplicates : " + nonRepeatNo);
29+
30+
}
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package lk.himash;
2+
3+
public class Illustration_03 {
4+
public static void main(String[] args) {
5+
6+
// Write a program to reverse the below paragraph
7+
8+
String word = "Hello My World";
9+
10+
StringBuilder out = new StringBuilder(); // method 01
11+
char[] charArr = word.toCharArray();
12+
for(int i = charArr.length - 1; i >= 0; i--) {
13+
out.append(charArr[i]);
14+
}
15+
System.out.println(out);
16+
17+
StringBuilder strBuilder = new StringBuilder(word);// method 02
18+
System.out.println(strBuilder.reverse());
19+
20+
StringBuffer strBuffer = new StringBuffer(word);// method 03
21+
System.out.println(strBuffer.reverse());
22+
}
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /