FirstNonRepeating
This commit is contained in:
26
FirstNonRepeating.java
Normal file
26
FirstNonRepeating.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Program to find first non-repeating character in a string (Dynamic Method).
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class FirstNonRepeating {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String str1;
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
System.out.println("Enter the string: ");
|
||||||
|
str1 = sc.next();
|
||||||
|
System.out.println("The given string is: " + str1);
|
||||||
|
for (int i = 0; i < str1.length(); i++) {
|
||||||
|
boolean unique = true;
|
||||||
|
for (int j = 0; j < str1.length(); j++) {
|
||||||
|
if (i != j && str1.charAt(i) == str1.charAt(j)) {
|
||||||
|
unique = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unique) {
|
||||||
|
System.out.println("The first non repeated character in String is: " + str1.charAt(i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
FirstNonRepeatingStatic.java
Normal file
21
FirstNonRepeatingStatic.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Program to find first non-repeating character in a string (Static Method).
|
||||||
|
|
||||||
|
public class FirstNonRepeatingStatic {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String str1 = "abcrabc";
|
||||||
|
System.out.println("The given string is: " + str1);
|
||||||
|
for (int i = 0; i < str1.length(); i++) {
|
||||||
|
boolean unique = true;
|
||||||
|
for (int j = 0; j < str1.length(); j++) {
|
||||||
|
if (i != j && str1.charAt(i) == str1.charAt(j)) {
|
||||||
|
unique = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unique) {
|
||||||
|
System.out.println("The first non repeated character in String is: " + str1.charAt(i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,4 +19,4 @@ public class InputFromKeyBoard {
|
|||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,8 @@ if the problem still persist then create a issue or use Google/Stack Overlflow f
|
|||||||
|14 | [Calculator](https://github.com/psavarmattas/Java-Projects/blob/master/Calculator.java) | Program that implements the arithmetic operation (Calculator) using switch statement.
|
|14 | [Calculator](https://github.com/psavarmattas/Java-Projects/blob/master/Calculator.java) | Program that implements the arithmetic operation (Calculator) using switch statement.
|
||||||
|15 | [ArithmeticOperations.java](https://github.com/psavarmattas/Java-Projects/blob/master/ArithmeticOperations.java) | Program to print the sum (addition), multiply, subtract, divide and remainder of two numbers. |
|
|15 | [ArithmeticOperations.java](https://github.com/psavarmattas/Java-Projects/blob/master/ArithmeticOperations.java) | Program to print the sum (addition), multiply, subtract, divide and remainder of two numbers. |
|
||||||
|16 | [InputFromKeyBoard.java](https://github.com/psavarmattas/Java-Projects/blob/master/InputFromKeyBoard.java) | Program to demonstrate input from keyboard using Command line argument. |
|
|16 | [InputFromKeyBoard.java](https://github.com/psavarmattas/Java-Projects/blob/master/InputFromKeyBoard.java) | Program to demonstrate input from keyboard using Command line argument. |
|
||||||
|
|17 | [FirstNonRepeatingStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/FirstNonRepeatingStatic.java) | Program to find first non-repeating character in a string (Static Method). |
|
||||||
|
|18 | [FirstNonRepeating.java](https://github.com/psavarmattas/Java-Projects/blob/master/FirstNonRepeating.java) | Program to find first non-repeating character in a string (Dynamic Method). |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +57,7 @@ if the problem still persist then create a issue or use Google/Stack Overlflow f
|
|||||||
|1 | [PrimeNoStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/PrimeNoStatic.java) | Program to display first n Prime number (Static Method). |
|
|1 | [PrimeNoStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/PrimeNoStatic.java) | Program to display first n Prime number (Static Method). |
|
||||||
|1 | [FibonacciSeriesStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/FibonacciSeriesStatic.java) | Program to generate fibonacci series upto n value (Static Method). |
|
|1 | [FibonacciSeriesStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/FibonacciSeriesStatic.java) | Program to generate fibonacci series upto n value (Static Method). |
|
||||||
|1 | [RootsOfQuadracticEquationStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/RootsOfQuadraticEquationStatic.javav) | Program to find the root of quadratic equation (Static Method). |
|
|1 | [RootsOfQuadracticEquationStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/RootsOfQuadraticEquationStatic.javav) | Program to find the root of quadratic equation (Static Method). |
|
||||||
|
|1 | [FirstNonRepeatingStatic.java](https://github.com/psavarmattas/Java-Projects/blob/master/FirstNonRepeatingStatic.java) | Program to find first non-repeating character in a string (Static Method). |
|
||||||
|2 | [EvenOddDynamic.java](https://github.com/psavarmattas/Java-Projects/blob/master/EvenOddDynamic.java) | Program to find out the number entered is Even/Odd (Dynamic Method). |
|
|2 | [EvenOddDynamic.java](https://github.com/psavarmattas/Java-Projects/blob/master/EvenOddDynamic.java) | Program to find out the number entered is Even/Odd (Dynamic Method). |
|
||||||
|2 | [ArithmeticOperations.java](https://github.com/psavarmattas/Java-Projects/blob/master/ArithmeticOperations.java) | Program to print the sum (addition), multiply, subtract, divide and remainder of two numbers |
|
|2 | [ArithmeticOperations.java](https://github.com/psavarmattas/Java-Projects/blob/master/ArithmeticOperations.java) | Program to print the sum (addition), multiply, subtract, divide and remainder of two numbers |
|
||||||
|2 | [LargestNumber.java](https://github.com/psavarmattas/Java-Projects/blob/master/LargestNumber.java) | Program to find out the largest number (Dynamic Method). |
|
|2 | [LargestNumber.java](https://github.com/psavarmattas/Java-Projects/blob/master/LargestNumber.java) | Program to find out the largest number (Dynamic Method). |
|
||||||
@@ -62,6 +65,7 @@ if the problem still persist then create a issue or use Google/Stack Overlflow f
|
|||||||
|2 | [PrimeNo.java](https://github.com/psavarmattas/Java-Projects/blob/master/PrimeNo.java) | Program to display first n Prime number (Dynamic Method). |
|
|2 | [PrimeNo.java](https://github.com/psavarmattas/Java-Projects/blob/master/PrimeNo.java) | Program to display first n Prime number (Dynamic Method). |
|
||||||
|2 | [FibonacciSeries.java](https://github.com/psavarmattas/Java-Projects/blob/master/FibonacciSeries.java) | Program to generate fibonacci series upto n value (Dynamic Method). |
|
|2 | [FibonacciSeries.java](https://github.com/psavarmattas/Java-Projects/blob/master/FibonacciSeries.java) | Program to generate fibonacci series upto n value (Dynamic Method). |
|
||||||
|2 | [RootsOfQuadracticEquation.java](https://github.com/psavarmattas/Java-Projects/blob/master/RootsOfQuadraticEquation.java) | Program to find the root of quadratic equation (Dynamic Method). |
|
|2 | [RootsOfQuadracticEquation.java](https://github.com/psavarmattas/Java-Projects/blob/master/RootsOfQuadraticEquation.java) | Program to find the root of quadratic equation (Dynamic Method). |
|
||||||
|
|2 | [FirstNonRepeating.java](https://github.com/psavarmattas/Java-Projects/blob/master/FirstNonRepeating.java) | Program to find first non-repeating character in a string (Dynamic Method). |
|
||||||
|3 | [Calculator](https://github.com/psavarmattas/Java-Projects/blob/master/Calculator.java) | Program that implements the arithmetic operation (Calculator) using switch statement.
|
|3 | [Calculator](https://github.com/psavarmattas/Java-Projects/blob/master/Calculator.java) | Program that implements the arithmetic operation (Calculator) using switch statement.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user