drjava

retrieving a random word from a txt file and getting no output, and no compiler error java

女生的网名这么多〃 提交于 2019-12-02 18:06:45
问题 i cannot change the shell of the program, the end goal is to choose a random word from a list of words in a txt file. i've scanned through this many many times, gone through the code one by one, tried many different things, but every time i run it, it compiles without a problem but i never get any output. i've even tried inserting some output in the private functions, but to no avail. can anyone see what is wrong with my code or can explain to me what is happening? import java.util.*; class

DrJava: Cannot run code using JDK8.0

北城余情 提交于 2019-12-01 22:57:18
Anyone having trouble using jdk 8.0 ?? Well, I don't know why I am facing some disturbances. Not sure why , after compiling a javacode in 'drjava' while I try to run it , it says ... " Current document is out of sync with the Interactions Pane and should be recompiled ! " I tried changing the compiler from JDK 8.0 to Eclipse Compiler 0.A48 it showed the same message .. after frequently recompiling and clicking the run button rather than using the shortcut key (F2) it ran !!!! then I toogled the compiler back to JDK 8.0 it ran also .(also the shortcut worked ) .. But after few compilation of

How to get the full fraction value of a division result in java? [duplicate]

五迷三道 提交于 2019-12-01 14:23:11
This question already has an answer here: Division of integers in Java [duplicate] 7 answers I am new to Java and I am using DrJava IDE for my testing. I have the following division 49700/40000 and it displays 1.0 instead of 1.2425. double t = 49700/40000; System.out.println(t); Is it something I am doing wrong? Try, this instead: double t = 49700/40000.0; System.out.println(t); If both operands are integers the result will be an integer which will be truncated, and then it will be cast in to a double. If, instead, one of the operands is a double, the result will be a double. Use float for

NullPointerExcetion Native Method Accessor… Hashing Words Issue

强颜欢笑 提交于 2019-11-29 18:09:37
I am writing a project that reads a file and sorts "Words". This code compiles correctly, yet then it gives me a null pointer exception. Any Ideas? import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Hashtable; public class Lab { Hashtable<String, Word> words = new Hashtable<String, Word>(); public void addWord(String s, int i) { if (words.containsKey(s)) { words.get(s).addOne(); words.get(s).addLine(i); } else { words.put(s, new Word(s)); words.get(s).addLine(i); } } public void main(String[] args) { System.out.println("HI"); File file = new

NullPointerExcetion Native Method Accessor… Hashing Words Issue

折月煮酒 提交于 2019-11-28 12:52:35
问题 I am writing a project that reads a file and sorts "Words". This code compiles correctly, yet then it gives me a null pointer exception. Any Ideas? import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Hashtable; public class Lab { Hashtable<String, Word> words = new Hashtable<String, Word>(); public void addWord(String s, int i) { if (words.containsKey(s)) { words.get(s).addOne(); words.get(s).addLine(i); } else { words.put(s, new Word(s));

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException Error

Deadly 提交于 2019-11-27 20:51:59
Hello I'm a new programmer at an high school level as a result I do not know much about programming and am getting quite a few errors which have been resolved while others I completely do not understand. I am to make a simple Check Box selection program where the user gets to pick between a variety of choices and depending on their action the image changes. The program itself compiles perfectly but when I run it however it gives me some complications. Here is my program: package components; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Workshop extends JPanel

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException Error

陌路散爱 提交于 2019-11-26 20:28:12
问题 Hello I'm a new programmer at an high school level as a result I do not know much about programming and am getting quite a few errors which have been resolved while others I completely do not understand. I am to make a simple Check Box selection program where the user gets to pick between a variety of choices and depending on their action the image changes. The program itself compiles perfectly but when I run it however it gives me some complications. Here is my program: package components;