AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 711 of 840

Working with csv files in Java

AmitDiwan
AmitDiwan
Updated on 17-Aug-2020 445 Views

OpenCSV has to be installed first, which is a parser library for Java. The dependency has to be mentioned in the pom.xml file in the maven project. After that, the below code can be utilized.Exampleimport java.io.FileReader; import java.io.*; public class Demo{    public static void readDataLineByLine(String file){       try{          FileReader my_filereader = new FileReader(file);          CSVReader csvReader = new CSVReader(my_filereader);          String[] nextRecord;          while ((nextRecord = csvReader.readNext()) != null){             for (String cell : nextRecord){         ...

Read More

What's the connection between Java and Blockchain?

AmitDiwan
AmitDiwan
Updated on 17-Aug-2020 265 Views

Blockchain has become a buzz word in the recent times. It is being tried to be implemented in every software for various purposes, to check how it would work efficiently given different scenarios. It is a decentralized technology. It basically is data that is digital in nature and every piece of data is known as a transaction. Hence, the date, time and amount of that specific transaction is stored in the blockchain. Every block is unique due to the unique code it has, that is also known as ‘hash’. It is created with the help of different specialized algorithms.Investors are ...

Read More

What are C++ features missing in Java?

AmitDiwan
AmitDiwan
Updated on 17-Aug-2020 1K+ Views

There are many features that can be seen in C++ but not in Java. A few of them have been listed below −No unsigned int option in JavaNo destructor in Java as well as ‘delete’ since garbage collector performs this operation for it.No friend classes or friend functions in Java.There are no pointers in Java.There is no typedef option in Java.Since Java is a purely object oriented language, there are no global variables or global functions.The concept of templates present in C++ can’t be found in Java.The ‘::’ scope resolution operator is not there, since there is no question of ...

Read More

Preconditions - Java

AmitDiwan
AmitDiwan
Updated on 14-Jul-2020 325 Views

Precondition to check if the list passed as parameter is empty or not. Let us see an example −Examplepublic void my_fun(List myList){    if (myList == null){       throw new IllegalArgumentException("List is null");    }    if (myList.isEmpty()){       throw new IllegalArgumentException("List is empty");    }    my_fun(myList); }A void function named ‘my_fun’ is defined that takes a list of objects as its parameters. If the list is null, it prints the relevant message. If the list has no elements in it, a specific message is displayed. The function is called by passing the list as ...

Read More

Java program to List all files in a directory and nested sub-directory - Recursive approach

AmitDiwan
AmitDiwan
Updated on 14-Jul-2020 602 Views

To list all files in a directory and nested sub-directory, the Java program is as follows −Exampleimport java.io.File; public class Demo{    static void print_recursively(File[] my_arr, int my_index, int sub_level){       if(my_index == my_arr.length)       return;       for (int i = 0; i < sub_level; i++)       System.out.print("\t");       if(my_arr[my_index].isFile())       System.out.println(my_arr[my_index].getName());       else if(my_arr[my_index].isDirectory()){          System.out.println("[" + my_arr[my_index].getName() + "]");          print_recursively(my_arr[my_index].listFiles(), 0, sub_level + 1);       }       ...

Read More

Perl vs Java

AmitDiwan
AmitDiwan
Updated on 13-Jul-2020 430 Views

JavaJava is an object oriented programming language as well as a computing platform.It is safe, quick and reliable.The code in Java is first converted into bytecode and then executed using a JVM (Java Virtual Machine).The java program that is converted into bytecode is stored with the help of the extension ‘.class’.Java doesn’t give any specific way in which associative arrays could be stored, instead there are implementations of various hash functions.Java programs that need to be run are stored with the extension ‘.java’.Java is a statically typed language, i.e type checking is performed during compile-time (not run-time).Single line comments in ...

Read More

Package Imports in JShell of Java 9

AmitDiwan
AmitDiwan
Updated on 13-Jul-2020 346 Views

In general, 10 packages are imported using the JShell.The following command shows the packages that were imported by default.jshell> /importOutputimport java.io.* import java.math.* import java.net.* import java.nio.file* import java.sql.* import java.util.* import java.util.regex* import java.util.function* import java.util.prefs* import java.util.stream.*Importing a specific package using JShelljshell> import java.util.*;

Read More

Why Kotlin will replace Java for Android App Development

AmitDiwan
AmitDiwan
Updated on 13-Jul-2020 317 Views

While working with Kotlin, Java libraries and frameworks can be used. This can be done with the help of advanced frameworks, without having to change the whole project. Java and Kotlin co-exist and can be present in the same project.Kotlin code can be placed inside Android Studio, without making the whole project in Kotlin.It is an open source platform that also helps in quick development of projects. It is easy, and readable, and considerably requires lesser coding in comparison to Java.Kotlin was developed by JetBrains, and IntelliJ is the IDE which Android Studio also uses.Kotlin plugin can be installed and ...

Read More

Can I query how much disk space certain rows or columns are taking up in MySQL?

AmitDiwan
AmitDiwan
Updated on 10-Jul-2020 637 Views

Yes, using the below syntax −select * from information_schema.tables where table_name=yourTableName;Let us first create a table −mysql> create table DemoTable1600    -> (    -> StudentId int,    -> StudentFirstName varchar(20)    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1600 values(100, 'Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1600 values(101, 'David'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1600 values(102, 'Carol'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select * from ...

Read More

Using Variables in JShell of Java 9

AmitDiwan
AmitDiwan
Updated on 09-Jul-2020 556 Views

In JShell 9, variables can be declared during a session. Once the user has logged into the session, they can declare a variable as follows −jshell> int val = 56 ;Italics indicate the terminal, once the user has logged in to their session.The above line would print the below output. The semicolon in the above line is optional, and it will run fine without the semicolon also.Outputval = = > 56When an integer value is defined by assigning it to a variable name on the JShell, and it is executed, by pressing ‘Enter’ key, it is displayed on the next ...

Read More
Showing 7101–7110 of 8,392 articles
« Prev 1 709 710 711 712 713 840 Next »
Advertisements