Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Java woes
Name: Dreyfus Date: March 4, 2008 at 18:46:50 Pacific OS: xp CPU/Ram: 2 gb
Comment:
I am having a bit of trouble working on a program in Java. The objective I am trying to complete here is to count all the occurrences of a text file, and assign the number of each occurrence into a one dimensional integer array. Here is my code.
----------------- public static int countLetters(String token, char letter) { int counter = 0; for (int n = 0; n < token.length(); n++) if (token.charAt(n) == letter) counter++; return counter; }
public static int[] frequency() throws IOException { int [] letters = new int[26]; String alphabet = "abcdefghijklmnopqrstuvwxyz"; Scanner inFile = new Scanner(new File("text.txt")); String token = "";
while (inFile.hasNext()) { token = inFile.next(); token = token.toLowerCase();
for (int n = 0; n < alphabet.length(); n++) { int counter = countLetters(token, alphabet.charAt(n)); letters[n] = counter; } } return letters; }
Summary: I have just started using Visual J++ 6. Its obvious to me now that Im a bit late. I actually thought I had hit a winner, because I wanted to: 1. Use the JDK 1.4 classes 2. Be able to create an executa...
Summary: Hey, I have just started learning how to program various languages, nothing too complex, but I want to learn Java in depth. I need the Java SDK but it is too large of a file to download on my measly ...
Summary: hai to all we have to generate a sine wave using java. can you help us by giving all the details (including details abt panels) can you try with this code package com.zdo.demo; import java.awt.Color; ...