Create Java SQL Date Object in Java

Maruthi Krishna
Updated on 05-Feb-2021 10:41:48

6K+ Views

Using the ConstructorThe java.sql.Date represents the date value in JDBC. The constructor of this class accepts a long value representing the desired date and creates respective Date object.Date(long date)You can create this object using this constructor.ExampleLive Demoimport java.text.ParseException; import java.text.SimpleDateFormat; public class Demo {    public static void main(String args[]) throws ParseException {         String str = "26-09-1989";       SimpleDateFormat obj = new SimpleDateFormat("dd-MM-yyyy");             long epoch = obj.parse(str).getTime();             System.out.println("Date value: "+epoch);       //Creating java.util.Date object       java.util.Date date = ... Read More

Create Dotchart Using ggplot2 Without Gridlines in R

Nizamuddin Siddiqui
Updated on 05-Feb-2021 10:39:53

283 Views

To create a dotchart using ggplot2 in R, we can use geom_dotplot function but the default gridlines will be in the output. If we want to remove the gridlines from the plot then theme function can be added in the rest of the command as theme(panel.grid=element_blank()).Example Live DemoConsider the below data frame −set.seed(214) x

Difference Between Java and Java EE

Maruthi Krishna
Updated on 05-Feb-2021 10:39:41

1K+ Views

JSE (Java Standard Edition)By using JavaSE you can develop stand-alone application ex: adobe reader, anti-virus, media players, etc. Java SE is also known as core java.lang: Language basics.util: Collection framework, events, data structure and other utility classes such as date.io: File operations, and other input and output operations.math: Multi precision arithmetics.nio: Non-blocking I/O framework for Java.net: Classes an API’s related to networking.security: This package provides classes and interfaces such as key generation, encryption, and decryption which belongs to the security framework.sql: Classes and interfaces for accessing/manipulating the data stored in databases and data sources.awt: Classes and interfaces to create GUI ... Read More

Create a Default Constructor in Java

Maruthi Krishna
Updated on 05-Feb-2021 10:37:53

3K+ Views

Default constructor (No-arg constructor)A no-arg constructor doesn’t accepts any parameters, it instantiates the class variables with their respective default values (i.e. null for objects, 0.0 for float and double, false for Boolean, 0 for byte, short, int and, long).There is no need to invoke constructors explicitly these are automatically invoked at the time of instantiation.Rules to be rememberedWhile defining the constructors you should keep the following points in mind.A constructor does not have return type.The name of the constructor is same as the name of the class.A constructor cannot be abstract, final, static and Synchronized.You can use the access specifiers ... Read More

Change Repeated Row and Column Names to Sequence in a Matrix in R

Nizamuddin Siddiqui
Updated on 05-Feb-2021 10:37:08

505 Views

To change the repeated row names and column names to a sequence, we first need to read those names in a vector then set them to row names and column names with make.unique function. For example, if a matrix has row names defined as A, B, A, B, A then it can be converted into A, B, A.1, B.1, A.2.Example1 Live DemoM1

Create Parameterized Constructor in Java

Maruthi Krishna
Updated on 05-Feb-2021 10:36:13

3K+ Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.There are two types of constructors parameterized constructors and no-arg constructors.Parameterized constructorsA parameterized constructor accepts parameters with which you can initialize the instance variables. Using parameterized constructor, you can initialize the class variables dynamically at the time of instantiating the class with distinct values.Examplepublic class StudentData {    private String name;    private int age;     ... Read More

Parametrized Constructors in Java

Maruthi Krishna
Updated on 05-Feb-2021 10:35:49

14K+ Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.Parameterized constructorsA parameterized constructor accepts parameters with which you can initialize the instance variables. Using parameterized constructor, you can initialize the class variables dynamically at the time of instantiating the class with distinct values.Syntaxpublic class Sample{    Int i;    public sample(int i){       this.i = i;    } }ExampleLive Demopublic class Test {   ... Read More

Use of Parameterized Constructor in Java

Maruthi Krishna
Updated on 05-Feb-2021 10:31:10

506 Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.There are two types of constructors parameterized constructors and no-arg constructors a parameterized constructor accepts parameters.The main purpose of a constructor is to initialize the instance variables of a class. Using a parameterized constructor, you can initialize the instance variables dynamically with the values specified at the time of instantiation.public class Sample{    Int i;    public ... Read More

Create Line Chart with Mean and Standard Deviation using ggplot2 in R

Nizamuddin Siddiqui
Updated on 05-Feb-2021 10:28:10

3K+ Views

Sometimes we have mean and standard deviation given for groups or factors, these are generally obtained from previous research studies and is referred to as the secondary data. In this case. the line chart with mean and standard deviation using ggplot2 can be created by defining the minimum and maximum inside geom_error function of ggplot2 package, where the difference between mean and standard deviation defines the standard deviation if the minimum is set as mean minus one standard deviation and the maximum is set as mean plus one standard deviation.ExampleConsider the below data frame − Live DemoGroup

Use Regular Expression in Java to Pattern Match

Maruthi Krishna
Updated on 05-Feb-2021 10:27:49

322 Views

A regular expression is a string of characters that defines/forms a pattern to search an input text. A regular expression may contain one or more characters, using a regular expression you can search or replace a string.Java provides the java.util.regex package for pattern matching with regular expressions. The pattern class of this package is a compiled representation of a regular expression. To match a regular expression with a String this class provides two methods namely −compile(): This method accepts a String representing a regular expression and returns an object of the Pattern object.matcher(): This method accepts a String value and creates ... Read More

Advertisements