bluej

Unable to print in Bluej console using PrintWriter

假装没事ソ 提交于 2019-12-24 21:15:37
问题 Consider the following code- import java.io.*; public class test { public static void main(String[] args) { PrintWriter out= new PrintWriter(System.out); out.println(1); out.close(); } } I run it on bluej for the first time and get output 1 on console. On running it again i get no output at all and same is the case for any subsequent tries. Would love to know why this is happening. 回答1: Ok, the problem why this method only works once is, that the PrintWriter.close() method also closes the

How to use a variable created in class1, in another class?

不打扰是莪最后的温柔 提交于 2019-12-24 19:04:14
问题 I’m trying to create a password programme that lets the user create an account and then be able to change username, password and access the account. This is where I’m at so far: class 2 import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class mainPage extends JFrame { create_account crAcc = new create_account(); change_username chU = new change_username(); change_password

Adding library in BlueJ

我是研究僧i 提交于 2019-12-24 12:51:46
问题 I am wondering if there a way to add Referenced library in blueJ. In eclipse, you can add the referenced library by clicking Build Path>> add external jar . How can you do it in blueJ? It is because I would like to use other library such as javax.mail, hibernate, and also log4j in BlueJ. 回答1: I didn't find your question clear, but if you are asking about adding a library into Java we should use the keyword import. For example if i want to import the libraries and classes of all objects I use:

Checking Password Code

倖福魔咒の 提交于 2019-12-21 22:59:02
问题 Problem Description: Some Websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rule is as follows: A password must have at least eight characters. A password consists of only letters and digits. A password must contain at least two digits. Write a program that prompts the user to enter a password and displays "valid password" if the rule is followed or "invalid password" otherwise. This is what I have so far: import

Java HangMan Game

こ雲淡風輕ζ 提交于 2019-12-14 04:15:05
问题 I'm doing this hangman project, and I'm almost done, but I can't get the output to show all of the correct letters in place of the underscore, instead it only shows the correct letter that was just entered. Please help. import java.util.Random; public class HangManGames { public static int i; public static int errors = 0; public static String wordList[] = {"alabama","alaska","arizona","arkansas","california","colorado","connecticut","delaware","florida","georgia","hawaii","idaho","illinois",

Class, interface, or enum expected when compiling

﹥>﹥吖頭↗ 提交于 2019-12-14 03:36:57
问题 I sat down and tried to write code for this prompt, and I made this. However, when I compile it in BlueJ, I get: class, interface, or enum expected . 1) How do I fix this error? It seems like I forgot something, but I cant remember what I forgot. 2) Do you think I fulfilled what the prompt was asking? Thanks. 回答1: I'm not going to do your homework for you but here are some hints: You need to put all your code inside a class You need to put the code in the main method . (Search on Google) the

Rectangle Class for BlueJ

左心房为你撑大大i 提交于 2019-12-13 22:11:20
问题 I am trying to write code for a rectangle class in BlueJ. When I compile my code I get the error "constructor Rectangle in class Rectangle cannot be applied to given types; required: no arguments; found: int, int, int, int; reason: actual and formal argument list differ in length". Also, I am confused on where to put the formula for a rectangle - width x height. I am trying to create class called rectangle that I could use in another class called picture. I am trying to use this class to make

Calling a method from a different class to another class & method

六月ゝ 毕业季﹏ 提交于 2019-12-13 10:35:29
问题 I have two classes, one called Driver and another called BankAccount. In Driver there is a method called Driver, and in BankAccount a method called Deposit. I'm getting an error that says, "non-static method Deposit() cannot be referenced from a static context" when I try to call BankAccount.Deposit from my Driver method. Any advice on what I should do to these lines of code to make it run. import javax.swing.JOptionPane; public class Driver { int choice; String number; //public Driver()

BlueJ import102x.IO [closed]

我的未来我决定 提交于 2019-12-13 10:30:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am new to BlueJ and I have an example of course grade class. The program was written in BlueJ IDE. It starts with the "import comp102x.IO; when I try to compile the program it does not work. It only points out to the .IO, part of the import comp102x.IO; by highlighting .IO; Can you please advise what I have to

Applet shows up blank, not initializing?

为君一笑 提交于 2019-12-13 09:36:46
问题 Hello everyone my name is Fyree! I have an assignment for an introductory Java course where I need to create a program that takes user input for the beginning values, and all five year values to make a line graph (but that is for another post), and also print the rate. Here is my problem, when I try to run this applet it opens (it compiles without error), but only shows up as a blank screen, and says applet not initialized at the bottom of the applet. I am not sure why this is (currently I am