-->
Skip to main content

Posts

Showing posts from September, 2020

Understanding public static void main in java

Understanding public static void main in java public static void main in java public static void main in java Let's split public static void main in java and understand it one by one. What is public static void main in java public :  public is an access modifier, which specifies from where and who can access this method. public makes the method available globally. public keyword is used before the main method to specify the starting execution point of the program and will be visible to JVM. Example : What will happen if we change public to private or protected or default with no access modifier below is the code snippet for all the three and its output public class JavaCodeGeekMainExample { private static void main(String[] args) { System.out.println("Hello World"); } } public class JavaCodeGeekMainExample { protected static void main(String[] args) { System.out.println("Hello World"); } } public class JavaCodeGeekMainExample { static ...

How to Convert String to Array in Java [2021]

How to Convert String to Array in Java [2021] In today's programming world, We generally need to Convert String to Array in Java, In this tutorial, we will cover how to convert String to Array in Java using two approaches. Using the Split method of String class. Using the  Pattern class compile method with regular expression.  Earlier we have covered different conversion like  Convert to String from Byte Array In Java ,  Convert String to Byte Array in Java  and  Convert Between Java Byte Array to Object In Java  which is also similar to our current requirement. Let's dive in for our current tutorial... How to Convert String to Array in Java  1. Using the Split method of String class. How to convert String to Array in Java Using Split method The split method is used to split the string around the regular expression passed. The split method will convert sampleString "Java Code Geek" to three separate Array Elements Java Code Geek. ...