EvilZone
Programming and Scripting => Java => : Packment June 20, 2014, 12:18:14 PM
-
This code have error somewhere around dnt knw what to do next
Please help me out
Import java.io.*;
Import java.util.Scanner;
Public class txtCharacter{
Public static Scanner kb = new Scanner;
Public static void main(String args[])throws IOException{
. Scanner in = new Scanner(new FileReader("file locatio");
char Character;
System.out.println("Enter character to count");
Character = kb.nextLineCharAt(0);
while(in.hasNext){
. String line = in.readLine();
. int count;
if(Character=!' '){
counter++;
}
}
System.out.println("The number of occurrence: "+ count);
}
In.close();
}
-
import java.io.*;
import java.util.Scanner;
public class txtCharacter {
public static Scanner kb = new Scanner(System.in);
public static void main(String args[])throws IOException{
. Scanner in = new Scanner(new FileReader("file locatio"));
char Character;
System.out.println("Enter character to count");
Character = kb.nextLineCharAt(0);
while(in.hasNext){
String line = in.readLine();
int count;
if(Character != ' '){
count++;
}
}
System.out.println("The number of occurrence: "+ count);
}
in.close();
}
Try that. I haven't tested it though.
-
This code have error somewhere around dnt knw what to do next
Please help me out
Import java.io.*;
Import java.util.Scanner;
Public class txtCharacter{
Public static Scanner kb = new Scanner;
Public static void main(String args[])throws IOException{
. Scanner in = new Scanner(new FileReader("file locatio");
char Character;
System.out.println("Enter character to count");
Character = kb.nextLineCharAt(0);
while(in.hasNext){
. String line = in.readLine();
. int count;
if(Character=!' '){
counter++;
}
}
System.out.println("The number of occurrence: "+ count);
}
In.close();
}
Where did you get this pile of shit from?
Seriously, this is worse than any code of any programming beginner in Java. It looks like copy&pasted from code in another language with an effortless try to transform it to Java. Learn the basics about Java and you might get anywhere.