Saturday, 23 May 2020
forEach Loop in Single Line of Code using JAVA 8 Feature
import java.util.List;
import java.util.ArrayList;
public class ForeachTest {
public static void main(String args[]) {
// create List
List<String> subjects = new ArrayList<String>();
subjects.add("C");
subjects.add("C++");
subjects.add("JAVA");
subjects.add(".NET");
//apply forEach in single line of code
subjects.forEach(System.out::println);
}
}
Friday, 22 May 2020
how to check url is valid or not in java
import java.net.URL;
import java.util.Scanner;
class URLTest {
//static method to validate URL
public static boolean isValid(String url){
try{
new URL(url).toURI();
return true;
}catch(Exception e){
//if exception generate than return false
return false;
}
}
public static void main(String[] args)
{
// user URL input
System.out.print("Enter URL: ");
Scanner sc = new Scanner(System.in);
String url = sc.nextLine();
//now check by method
if(isValid(url)){
System.out.print("\nYes URL is Valid ");
}else{
System.out.print("\n No URL is Not Valid ");
}
}
}
Tuesday, 19 May 2020
Monday, 11 May 2020
Sunday, 10 May 2020
Saturday, 9 May 2020
Sunday, 3 May 2020
Subscribe to:
Posts (Atom)
-
/* action perform event for insert data into table Database : student_info Table : class5 root username of mysql db mysql@123 is a pas...
-
index.html <html> <head> <title>TODO supply a title</title> <meta charset="UTF-8...
-
private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) { // TODO add your han...