Skip to content

Instantly share code, notes, and snippets.

View bikashdaga's full-sized avatar

Bikash Daga (Jain) bikashdaga

  • Bangalore, India
View GitHub Profile
@bikashdaga
bikashdaga / Reverse a String in Java
Last active March 7, 2022 10:45
How to Reverse a String in Java
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;
}
@bikashdaga
bikashdaga / Java Constructor Overloading
Created March 3, 2022 10:46
Constructor Overloading in Java
Input:
public class ConstructorEG {
String name;
Integer number;
ConstructorEG(){ // default constructor
System.out.println("Default Constructor called");
}
@bikashdaga
bikashdaga / Java Linear Search Algorithm
Last active March 3, 2022 10:38
Linear Search Algorithm in Java
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);