You can also use switch-case for comparing Strings (from jdk7), it works similar to equals(). You may also use equalsIgnoreCase() (Java is case sensitive) if you want your output to be correct regardless of upper case or lower case letters.
I installed JMF a few days back on my system, JMStudio was able to play few files at that time. I was using framework for creating a media player. I tried to add plugins for supporting more file formats but things did not worked correctly, so I uninstallled everything realated to JMF. I installed it again and now JMStudio is not playing any file and reports the following error.The PlayerApplet given in jmf-guide gives error "Unable to handle format : <details>" for every file.
Does anyone know what is the problem and how to fix it .
I copied the program from its current project(Cryptography) to another project and it ran successfully.
I deleted the project Cryptography(including sources), and started a new project named cryptography.
Copied the file again to the project, but it does not executes even now.
The only thing that resolved the problem was
1. delete existing project
2. restart netbeans
3. create new project named cryptography(or any other) and copy files to it.
Please share any information regarding the problem if you know why exactly it is happening.
Thanks
I wrote the code in netbeans and executed it, but I getting an error
"Error: Could not find or load main class CaesarCipher
Java Result: 1"
When I am running it in command prompt, it executes successfully. Please tell me why I am getting this error and the remedy.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
public static void main(String[] args) {
buf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ex");
CaesarCipher obj = new CaesarCipher();
obj.showMenu();
}
void showMenu(){
System.out.println("1. Encrypt");
System.out.println("2. Decrypt");
System.out.println("3. Exit");
System.out.println("\n Enter your choice");
int ch=0;
try {
ch = Integer.parseInt(buf.readLine());
} catch (Exception e) {
System.out.println("Please Enter a number");
}
switch(ch){
case 1: encrypt();
break;
case 2: decrypt();
break;
case 3: System.exit(0);
default: System.out.println("please enter a valid choice");
}
}
void encrypt(){
System.out.println("Enter the Plain text:");
StringBuilder input=null;
try {
input = new StringBuilder(buf.readLine());
} catch (Exception e) {
}
for (int i = 0; i < input.length(); i++) {
System.out.println((int)input.charAt(i));
}
}