-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f3804c
commit 1ad083f
Showing
20 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<component name="AdditionalModuleElements"> | ||
<content url="file://$MODULE_DIR$" dumb="true"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>groupId</groupId> | ||
<artifactId>java8</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Add dependencies here if needed --> | ||
|
||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> | ||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<version>42.7.3</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
Binary file not shown.
29 changes: 29 additions & 0 deletions
29
src/main/java/interview_Coding_Questions/FrequencyOfEachCharInArray.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
public class FrequencyOfEachCharInArray { | ||
public static void main(String[] args) { | ||
|
||
List<Integer> arr = Arrays.asList(1,2,3,4,5,62,4,1,0,9,8,7,6,8,3,2,1); | ||
Map<Integer, Long> fre = arr.stream().collect(Collectors.groupingBy(Function.identity(),Collectors.counting())); | ||
|
||
System.out.println(fre); | ||
|
||
System.out.println("another method"); | ||
|
||
List<Integer> array = Arrays.asList(1,2,3,4,5,62,4,1,0,9,8,7,6,8,3,2,1); | ||
Map<Integer,Integer> m =new HashMap<>(); | ||
for (int a:array){ | ||
System.out.println(a); | ||
} | ||
|
||
System.out.println(m); | ||
|
||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package jdbcPostgresql; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
|
||
public class PostgresqlOne { | ||
public static void main(String[] args) { | ||
|
||
String url = "jdbc:postgresql://localhost:5432/name"; | ||
String user = "postgres"; | ||
String password = "sameer"; | ||
try(Connection con = DriverManager.getConnection(url,user,password)) { | ||
if(con !=null){ | ||
System.out.println("database connection is right"); | ||
Statement statement =con.createStatement(); | ||
String createTable = "CREATE TABLE IF NOT EXISTS name (" + | ||
"id SERIAL PRIMARY KEY, " + // Optionally keep this if you want a unique identifier | ||
"name VARCHAR(50) NOT NULL, " + | ||
"age INT NOT NULL)"; | ||
|
||
|
||
statement.execute(createTable); | ||
System.out.println("Table 'name' created or already exists."); | ||
|
||
String addData ="INSERT INTO name (name, age) " | ||
+ "VALUES ('sameer', 23), " | ||
+ "('ovi', 11), " | ||
+ "('rahee', 19)"; | ||
|
||
statement.execute(addData); | ||
System.out.println("data added in name DB"); | ||
|
||
//for printing data from name DB | ||
|
||
String select ="SELECT * FROM name"; | ||
ResultSet resultSet =statement.executeQuery(select); | ||
|
||
while (resultSet.next()){ | ||
int id =resultSet.getInt("id"); | ||
String name =resultSet.getString("name"); | ||
int age =resultSet.getInt("age"); | ||
System.out.println(String.format("Id : %d \n Name : %s\n Age : %d",id,name,age)); | ||
} | ||
|
||
|
||
|
||
|
||
}else{ | ||
System.out.println("failed to make connection"); | ||
} | ||
|
||
}catch (Exception e){ | ||
System.out.println(e.getMessage()); | ||
} | ||
|
||
} | ||
} |
Binary file added
BIN
+2.27 KB
target/classes/interview_Coding_Questions/FrequencyOfEachCharInArray.class
Binary file not shown.
Binary file added
BIN
+1.45 KB
target/classes/interview_Coding_Questions/FrequencyOfEachCharInString.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.