Coders Packet

Java program to check a string Contain all type of Characters or not.

By KOMMU GANESH

In this program, we are going to build a code to check Whether a string contain special characters or not. Using java programming language.

Process of checking System:

In General, every String has its own Characters. So the below java program allows to check the given string contains All characters, like Digits, special Characters and Upper Case Letters.
Using different kinds of statements and loops, the Printing system is allocated to print the String.This is all about the brief description of the below java project.

import java.util.*;
public class Main
{
 public boolean validDigit(String s)
 {
  char arr[] = s.toCharArray();
  boolean boo =false;
  for(char x : arr)
  {
   if(Character.isDigit(x))
   {
    boo = true;
    break;
   }
  }
  return boo;  
 }
 public boolean validUpperCase(String s)
 {
  char arr[] = s.toCharArray();
  boolean boo =false;
  for(char x : arr)
  {
   if(Character.isUpperCase(x))
   {
    boo = true;
    break;
   }
  }
  return boo; 
  
 }
 public boolean validSpecial(String s)
 {
  char arr[] = s.toCharArray();
  boolean boo =false;
  for(char x : arr)
  {
   if(!Character.isLetterOrDigit(x))
   {
    boo = true;
    break;
   }
  }
  return boo; 
 }
 public static void main(String[] args) 
 {
     Scanner scan =  new Scanner(System.in);
     System.out.println("Enter a String :");
  String s = scan.next();
  Main obj = new Main();
  if(obj.validDigit(s) && obj.validSpecial(s) && obj.validUpperCase(s))
   System.out.println("Given string contains Digits, Special characters and UpperCase Characters");
  else
   System.out.println("Given string does not contain Digits, Special characters and UpperCase Characters");  
 }
}

Output 1:-

 String Contain Digits, Special Characters and Uppercase Characters

Output 2 :-

 String  Does not Contain Digits, Special Characters and Uppercase Characters

Download project

Reviews Report

Submitted by KOMMU GANESH (Ganesh09)

Download packets of source code on Coders Packet