Showing posts with the label maven

you should install 'babel-loader@7'. || babel version

If you are Getting any error in compiling main.js or app.js or in Entry file of React App You have to Update Babel versions and dependency npm install -D babel-loader @babel/core @babel/preset-env webpack And change config file options: {           presets: ['@babel/preset-env']         }

Array of string arguments in Java || string args[]

public static void main( String []args ). This string args is used to taking input from console,when we access the file and give some input value. suppose our filename is And the className, which has Main method is ABC. To compile this we Run command- javac After the compilation this will generate class code that is- ABC.class When we run this using- java ABC “ if here we pass some value this value will go to the args ”. so thats why we use it.

Type error “Java.util.Scanner.nosuchelementexception” || Exception || nosuchelementexception

This exception extends the  RuntimeException  class and thus, belongs to those exceptions that can be thrown during the operation of the  Java Virtual Machine (JVM) . It is an unchecked exception and thus, it does not need to be declared in a method’s or a constructor’s throws clause. The NoSuchElementException in Java The  NoSuchElementException   can be thrown by the following methods : Enumeration::nextElement() NamingEnumeration::next() StringTokenizer::nextElement() Iterator::next() All the aforementioned methods try to return the next element of an  enumeration  and throw that exception, in order to indicate that no more elements exist. example- import   java . util . HashSet ; import   java . util . Hashtable ; import   java . util . Set ; import   java . util . StringTokenizer ; public   class   NoSuchElementExceptionExample { public   static   void   main ( String [] args ) { Set sampleSet = new   HashSet (); Hashtable sampleTable =

Is-a and Has-a RelationShip

In java or other object oriented programming language is-a and has-a are two type of relationship under the concepts of inheritance. suppose we have three class Car. subaru. engine. subaru is a car — its a is-a  relationship  between  class  subaru and  class  car. car has a engine — its a has-a  relationship  between  class  car and  class  engine.

Java class Name main

We can put the class name main their is no  compilation error or run time error . class main { public static void main(String []args) { // do your code } } now suppose our filename is and now we are compiling it with command prompt- compiling- javac Run- java main

What does the "String[ ] args" in a Java main method actually mean?

in Java  args   contains the supplied  command-line arguments  as an array of  String   objects. In other words, if you run your program as  java MyProgram one two  then  args will contain  [ "one" , "two" ] . If you wanted to output the contents of  args , you can just loop through them like this... public class ArgumentExample { public static void main ( String [] args ) { for ( int i = 0 ; i < args . length ; i ++) { System . out . println ( args [ i ]); } } }

What is Singleton class and how to use it in Java?

What is Singleton class and how to use it in Java? Singleton pattern helps us to keep only one Instance of class at any Time. The purpose of singleton is to Control object creation by keeping private Constructor. Example- public class MySingleTon { private static MySingleTon myObj; /** * Create private constructor */ private MySingleTon(){ } /** * Create a static method to get instance. */ public static MySingleTon getInstance(){ if(myObj == null){ myObj = new MySingleTon(); } return myObj; } public void getSomeThing(){ // do something here System.out.println("I am here...."); } public static void main(String a[]){ MySingleTon st = MySingleTon.getInstance(); st.getSomeThing(); } } Reference on Quora