AmitDiwan has Published 10744 Articles

How to combine duplicate values into one with corresponding value separated by hyphens in MySQL?

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 12:36:56

4K+ Views

To combine, use GROUP_CONCAT() function to combine some attributes in two rows into one. As a separator, use hyphens.Let us first create a table −mysql> create table DemoTable1386    -> (    -> Title varchar(255),    -> Name varchar(60)    -> ); Query OK, 0 rows affected (0.67 sec)Insert some ... Read More

Java Program to Find the closest pair from two sorted arrays

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 12:03:33

341 Views

To find the closest pair from two sorted array, the Java code is as follows −Example Live Demopublic class Demo {    void closest_pair(int my_arr_1[], int my_arr_2[], int arr_1_len, int arr_2_len, int sum){       int diff = Integer.MAX_VALUE;       int result_l = 0, result_r = 0;   ... Read More

Implement numbering in MySQL GROUP_CONCAT

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:58:17

539 Views

Let us first create a table −mysql> create table DemoTable1627     -> (     -> FirstName varchar(20),     -> LastName varchar(20)     -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command.mysql> insert into DemoTable1627 values('John', 'Smith'); Query OK, ... Read More

Java Program to find reminder of array multiplication divided by n

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:58:16

234 Views

To find reminder of array multiplication divided by n, the Java code is as follows −Example Live Demoimport java.util.*; import java.lang.*; public class Demo{    public static int remainder(int my_arr[], int arr_len, int val){       int mul_val = 1;       for (int i = 0; i < ... Read More

Java program to expand a String if range is given?

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:53:10

337 Views

To expand a String if range is given, the Java code is as follows −Example Live Demopublic class Demo {    public static void expand_range(String word) {       StringBuilder my_sb = new StringBuilder();       String[] str_arr = word.split(", ");       for (int i = 0; ... Read More

Java Program to Count trailing zeroes in factorial of a number

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:47:03

826 Views

To count trailing zeroes in factorial of a number, the Java code is as follows −Example Live Demoimport java.io.*; public class Demo{    static int trailing_zero(int num){       int count = 0;       for (int i = 5; num / i >= 1; i *= 5){   ... Read More

Java program to count the characters in each word in a given sentence

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:43:04

506 Views

To count the characters in each word in a given sentence, the Java code is as follows −Example Live Demoimport java.util.*; public class Demo{    static final int max_chars = 256;    static void char_occurence(String my_str){       int count[] = new int[max_chars];       int str_len = my_str.length(); ... Read More

Java Program to Convert Iterator to Spliterator

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:39:44

138 Views

To convert Iterator to Spliterator, the Java code is as follows −Example Live Demoimport java.util.*; public class Demo{    public static Spliterator getspiliter(Iterator iterator){       return Spliterators.spliteratorUnknownSize(iterator, 0);    }    public static void main(String[] args){       Iterator my_iter = Arrays.asList(56, 78, 99, 32, 100, 234).iterator(); ... Read More

Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:37:16

232 Views

To check whether it is possible to make a divisible by 3 number using all digits in an array, the Java code is as follows −Example Live Demoimport java.io.*; import java.util.*; public class Demo{    public static boolean division_possible(int my_arr[], int n_val){       int rem = 0;     ... Read More

Java Program to check if count of divisors is even or odd

AmitDiwan

AmitDiwan

Updated on 08-Jul-2020 11:35:48

211 Views

To check if the count of divisors is even or odd, the Java code is as follows −Example Live Demoimport java.io.*; import java.math.*; public class Demo{    static void divisor_count(int n_val){       int root_val = (int)(Math.sqrt(n_val));       if (root_val * root_val == n_val){         ... Read More

Advertisements