Category Archive: Java

Nov 24

Printing the First Repeated Character in Given String using Java

This question is asked by Genesis On nov 21, 2010 [code language=”java”] import java.io.*; public class FirstRepeat { public static void main(String[] args) throws IOException { System.out.println("Enter the String"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); char[] chArray = str.toCharArray(); char repeated = ‘ ‘; for(int i=0; i { char compare1 = …

Continue reading »

Nov 22

Merging and Sorting two arrays using Java

This is the question asked by Genesis on Nov 20, 2012 [code language=”java”] <import java.util.Arrays; public class MergingTwoArrays { public static void main(String[] args) { int[] array1 = new int[3]; array1[0] = 1; array1[1] = 38; array1[2] = 34; int[] array2 = new int[3]; array2[0] = 17; array2[1] = 23; array2[2] = 2; int[] array3 …

Continue reading »

Nov 19

Connecting a database in java

[code language=”java”]</code> <code> import java.sql.*; Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://yourdatabasehost/Databasename","username","password"); </code> [/code] You should download jdbc driver (just google it you will find. It’s not an application it is . you should build path to the downloaded jar file. It looks complex but very easy. Feel free to comment. watch the below video.