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
Input: | |
public class ScalerTopics | |
{ | |
public static void main(String[] args) { | |
int[] array = new int[] {5, 3, 12, 9, 45, 1, 22}; | |
int K = 9; | |
int result = linearSearch(array, K); | |
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
Input: | |
public class ConstructorEG { | |
String name; | |
Integer number; | |
ConstructorEG(){ // default constructor | |
System.out.println("Default Constructor called"); | |
} |
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
1. Using toCharArray(): | |
public static String reverse(String str) | |
{ | |
String rev=""; | |
char[] finalarray = str.toCharArray(); | |
for (int i = finalarray.length - 1; i >= 0; i--) | |
rev+=finalarray[i]; | |
return rev; | |
} |