Posts

magical vowels problems

Consider following letters :  a, e, i, o, u print Magical subsequence of the string that contains all five vowels in order.  import java.util.regex.Matcher; import java.util.regex.Pattern; public class OnMobile { public static int i=1; static char getNext(){ i=i+1;     String s2="aeiou";     if(i>s2.length()){         i=i-2;     }     else if(i==s2.length()){         i=i-1;     }     return s2.charAt(i);      }     static int longestSubsequence(String s) {      Pattern pattern = Pattern.compile(".a.e.i.o.u.");      Matcher matcher = pattern.matcher(s);      boolean matchFound = matcher.matches();      if(!matchFound){      return 0;      }             int count=0;

Windows cannot be installed to this disk. The selected disk is not of the GPT partition style

Image
Installing using the MBR or GPT partition style "Windows cannot be installed to this disk. The selected disk is not of the GPT partition style" Step:         Exit your Windows Setup     Press shift + f10   ( command prompt will open) Enter :   diskpart                list disk               select disk 0               clean               exit Your are done Process with windows installation

java program to rotate an array n time

 Rotating an array n number of time public class ArrayRotation { public static void main(String[] args) { int rotate= 5; int arr2[]={0,1,2,3,4,5,6,7,8,9,10}; int temp=0; int a; int b; while(rotate!=0){ for(int i=0;i<arr2.length;i++){ if(i==0) { a=arr2[i]; arr2[i]=arr2[arr2.length-1]; } else a=temp; if(i<arr2.length-1)  b=arr2[i+1]; else b=0; temp=b; if(i<arr2.length-1) arr2[i+1]=a; System.out.print(arr2[i]+" "); } rotate--; System.out.println(); } } } Output 10 0 1 2 3 4 5 6 7 8 9  9 10 0 1 2 3 4 5 6 7 8  8 9 10 0 1 2 3 4 5 6 7  7 8 9 10 0 1 2 3 4 5 6  6 7 8 9 10 0 1 2 3 4 5 

java environment setup

download and install java ( Click to Download ) windows admin user Select Start, select Control Panel. double click System, and select the Advanced tab. Or go to your computer in the address bar copy paste ( Control Panel\System and Security\System ) Click Environment Variables In the Edit System Variable new add variable name JAVA_HOME                 variable value C:\Program Files\Java\jdk1.8.0_111 Edit PATH  Add at the end of PATH variable ;  ';'  symbol add %JAVA_HOME%\bin; Ok Non admin user Select Start, select Control Panel. double click System, and select the Advanced tab. Or go to your computer in the address bar copy paste ( Control Panel\System and Security\System ) Click  Environment Variables In the Edit User Variables

Introduction to java

Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation). Java is "write once, run anywhere" meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM).

volatile keyword in Java best explanation

Image
volatile Keyword use to maintain a variable in Main memory .      class text      {           static int i= 6;      } Suppose that two threads are working on text.i If two threads run on different processors, If one thread modifies its value the change reflect to other threads and in the original main memory. volatile variables are not create local copy. volatile would not be sufficient to make thread-safe, synchronization would still be needed. Using volatile variables reduces the risk of memory, because any write to a volatile variable establishes a happens-before relationship with subsequent reads of that same variable. This means that changes to a volatile variable are always visible to other threads. read more about mutual exclusion , visibility and Atomic .

Cryptography Engine Classes

The following engine classes are available: SecureRandom : used to generate random or pseudo-random numbers.              SecureRandom secureRandom = new SecureRandom()              secureRandom.getInstance();              secureRandom.getInstanceStrong()              synchronized public void setSeed(byte[] seed)              public void setSeed(long seed)              synchronized public void nextBytes(byte[] bytes)              byte[] generateSeed(int numBytes) MessageDigest : used to calculate the message digest (hash) of specified data. Signature : initialized with keys, these are used to sign data and verify digital signatures. Cipher : initialized with keys, these used for encrypting/decrypting data. There are various types...