MySQL Error 1062: Duplicate Entry Explanation

AmitDiwan
Updated on 09-Sep-2019 07:59:17

3K+ Views

Let’s say you have set column values as unique key and try to insert duplicate values in the table. This will lead to ERROR 1062 (23000): Duplicate entry.Let us first create a table -mysql> create table DemoTable776 (    FirstValue int,    SecondValue int,    unique key(FirstValue, SecondValue) ); Query OK, 0 rows affected (0.74 sec)Insert some records in the table using insert command. While inserting duplicate value, the same error arises as shown below -mysql> insert into DemoTable776 values(10, 20); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable776 values(10, 40); Query OK, 1 row affected (0.15 ... Read More

What Are Generic Methods in Java

Maruthi Krishna
Updated on 09-Sep-2019 07:52:25

800 Views

Similar to generic classes you can also define generic methods in Java. These methods use their own type parameters. Just like local variables, the scope of the type parameters of the methods lies within the method.While defining a generic method you need to specify the type parameter within the angle brackets (< T >). This should be placed before the method's return type.You can have multiple type parameters separated by commas. A type parameter, also known as a type variable, is an identifier that specifies a generic type name.The type parameters can be used to declare the return type and ... Read More

Throw Object of Generic Class in Java

Maruthi Krishna
Updated on 09-Sep-2019 07:48:27

662 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any data type.Example Live Democlass Student{    T age;    Student(T age){       this.age = age;    }    public void display() {       System.out.println("Value of age: "+this.age);    } } public class GenericsExample ... Read More

Java Generics in Static Methods

Maruthi Krishna
Updated on 09-Sep-2019 07:42:47

4K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.Generics for static methodsWe can use generics for static methods Live Demopublic class GenericMethod {    static void sampleMethod(T[] array) {       for(int i=0; i

Passing Primitive Values While Instantiating a Parameterized Type Generic in Java

Maruthi Krishna
Updated on 09-Sep-2019 07:36:48

580 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.Example Live Democlass Student{    T age;    Student(T age){       this.age = age;    }    public void display() {       System.out.println("Value of age: "+this.age);    } } public class GenericsExample { ... Read More

Create an Array of Generics Type in Java

Maruthi Krishna
Updated on 09-Sep-2019 07:33:09

1K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.Example Live Democlass Student{    T age;    Student(T age){       this.age = age;    }    public void display() {       System.out.println("Value of age: "+this.age);    } } public class GenericsExample { ... Read More

Check If an URL is Valid Using Java

Maruthi Krishna
Updated on 09-Sep-2019 07:30:14

3K+ Views

The URL class of the java.net package represents a Uniform Resource Locator which is used to point a resource(file or, directory or a reference) in the worldwide web.This class provides various constructors one of them accepts a String parameter and constructs an object of the URL class. While passing URL to this method if you used an unknown protocol or haven’t specified any protocol this method throws a MalformedURLException.Similarly, the toURI() method of this class returns an URI object of the current URL. If the current URL is not properly formatted or, syntactically incorrect according to RFC 2396 this method throws ... Read More

Are Generics Applied at Compile Time or Run Time?

Maruthi Krishna
Updated on 09-Sep-2019 07:17:53

686 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.Example Live Democlass Student{    T age;    Student(T age){       this.age = age;    }    public void display() {       System.out.println("Value of age: "+this.age);    } } public class GenericsExample { ... Read More

Instantiate Type Parameter T in Java

Maruthi Krishna
Updated on 09-Sep-2019 07:14:13

5K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.Example Live Democlass Student {    T age;    Student(T age){       this.age = age;    }    public void display() {       System.out.println("Value of age: "+this.age);    } } public class GenericsExample ... Read More

ReadUTF and WriteUTF Methods in Java

Maruthi Krishna
Updated on 06-Sep-2019 14:10:39

4K+ Views

Unicode (UTF) − Stands for Unicode Translation Format. It is developed by The Unicode Consortium. if you want to create documents that use characters from multiple character sets, you will be able to do so using the single Unicode character encodings. It provides 3 types of encodings.UTF-8 − It comes in 8-bit units (bytes), a character in UTF8 can be from 1 to 4 bytes long, making UTF8 variable width.UTF-16-8 − It comes in 16-bit units (shorts), it can be 1 or 2 shorts long, making UTF16 variable width.UTF-32 − It comes in 32-bit units (longs). It is a fixed-width ... Read More

Advertisements