This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
import java.util.Arrays; | |
public class ArraySort { | |
public static void main(String[] args) { | |
int[] array = {1, 5, 2, 3, 6, 5, 3, 5, 8}; | |
int temp = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
import java.util.*; | |
public class StringWordCount { | |
public static void main(String[] args) { | |
String line = "Sri Lanka is a beautiful country. It is an island."; | |
String[] words = line.trim().replace(".", "").replace(",", "").split(" "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
public class ReverseString { | |
public static void main(String[] args) { | |
String name = "abcdefg"; | |
// method 1 | |
StringBuffer stringBuffer = new StringBuffer(name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
public class RemoveDuplicates { | |
public static void main(String[] args) { | |
String line = "Sri Lanka is a beautiful country. It is an island"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.other.map; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
public class ListToMap { | |
public static void main(String[] args) { | |
List<Employee> employeeList = new ArrayList<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.other.set; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
public class ListToSet { | |
public static void main(String[] args) { | |
List<String> list = Arrays.asList("FFF", "BBB", "CCC", "DDD", "DDD"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.other; | |
import java.util.*; | |
public class ListToArray { | |
public static void main(String[] args) { | |
List<Integer> list = Arrays.asList(1,2,3,4,5,6,7,3,2,1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
import java.util.Arrays; | |
public class ArraySort { | |
public static void main(String[] args) { | |
int[] array = {1, 5, 2, 3, 6, 5, 3, 5, 8}; | |
int temp = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
public class PalindromeCheck { | |
public static void main(String[] args) { | |
int number = 121; | |
int sum = 0; | |
int r; | |
int temp = number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
public class ReverseNumber { | |
public static void main(String[] args) { | |
int i = 1234567; | |
int temp = 0; | |
while (i != 0) { |
OlderNewer