32,199 Topics
| |
I have a private ArrayList in a class and I'd like to be able to access it outside of this class, what would be the proper way to do this? Right now I've just made the ArrayList public but I would like to allow it to be private. Should I … | |
package array1; import javax.swing.*; import java.util.Random; class pickrand{ Random rand = new Random(); public static String get(String[] array){ int rnd = rand.nextInt(array.length); return array[rnd]; } } /*********************************************************************/ public class Array1 { public static void main(String[] args) { int size = 10; String[] passcheck = new String[size]; String[] pass = {"abc345", … | |
I need to make an Evil Hangman game for my Java class. Can anyone help please? I really need help figuring out how to put the words into "families". Also, if you see any problems with my code or any ways that I can make the code simpler, please let … | |
hi, I prepare for an application to monitor network with the SNMP protocol,I have searched for APIs to help me in developping the code with java language like SNMP4j,but I'am just confused,is this API let me develop a class for searching the MIB values of the agent and thanks. | |
Hello to all java programmers, I have a problem about method and array. The program will display the second highest value of the inputed set of numbers in the main method. The problem is that it won't accept less than four inputs which mean it is necessary to put 4 … | |
| import java.util.*; import java.io.IOException; import java.util.Scanner; import java.util.Random; public class LinkedListProgram { public static void main(String[] args) throws IOException { int i,number, ran; Scanner sc = new Scanner(System.in); LinkedList<Integer> list = new LinkedList<Integer>(); ListIterator li; String line; Random random = new Random(); int pick = random.nextInt(150); System.out.println("Enter # of nodes"); … |
I'm using a loop to get user input and compare it; Idk why but on the first iteration of the while it works fine and displays only once. Second run thru I get two prompts, hoping someone can point out where I'm screwing up. public static void main(String[] args) { … | |
I need to make a program that runs two threads. One that outputs ping and sleeps for ten second and one that outputs pong and sleeps for ten seconds. Everything works except instead of sleeping for ten seconds everytime the thread is ran its just jumps to the second thread … | |
I have this Singleton class: package com.CCharles.Singleton; import java.util.ArrayList; public enum Singleton{ INSTANCE; public void createList(){ ArrayList arrayList = new ArrayList(); for(int i=1;i<101;i++) { arrayList.add("Job "+i); } for(int i=1;i<101;i++) { System.out.println(arrayList.get(3)); } System.out.println("DONE"); } public void sayHello(){ System.out.println("Hello World"); } } and I am accessing Using: package com.CCharles.Singleton; import com.CCharles.Singleton.Singleton; … | |
Hi, I have an application that is running in the system tray. It displays a popup menu when the user right clicks on it. I need to set shortcut keys for displaying the popmenu and also for the menu items. Is this achievable? If yes, then please advice. | |
I'm very new to programming, so sorry if this is a dumb question. Is it possible to write a program that can view the source of a webpage and extract and re-write a certain part of the code? For example, I would want the program to view the source of … | |
| Learning Java, I have never used the keyword "this". So I am wondering when it is smart to use it. I know that it does prevent name conflicts: public class test { int x; int y; public test(int x, int y) { this.x = x; this.y = y; } } … |
| So my java class is a joke, and we're expected to learn how to do our assignments via the web...I'm a hard worker, but I'm just not good at this. [Assignment pic](http://oi50.tinypic.com/aw3zx2.jpg) There's the assignment image. I think i got how to do the first part with the adding random … |
package gui; import javax.swing.*; Import java.awt.event.*; import java.applet.Applet; public class FE extends Applet implements ActionListener { private JLabel lb = new JLabel("Enter text :"); private JTextField jtf1 = new JTextField(10); private JButton jb = new JButton("ENTER"); private JLabel lb2 = new JLabel(" "); public void init() { add(lb); add(jtf1); add(jb); … | |
The output of the following line of code is: Not Done End boolean notDone = false; if (notDone = true) System.out.print("Not "); if( notDone = false) System.out.print("Done "); System.out.println("End"); The answer is false but I am having a hard time understanding why. Aren't the if statements setting notDone equal to … | |
I keep getting an error with the "ButtonListener." I don't know what it is that's causing it, but help would be appreciated. import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MovingCarPanel extends JPanel { private int delay = 2; private Car car; private Timer … | |
I Have This Workers List: private List<Worker> buildWorkerList( Producer producer ) { List<Worker> workerList = new ArrayList<Worker>( 11 ); workerList.add( new WorkerImpl( "Garnett", producer ) ); workerList.add( new WorkerImpl( "Durant", producer ) ); workerList.add( new WorkerImpl( "Xavier", producer ) ); workerList.add( new WorkerImpl( "Daniel", producer ) ); workerList.add( new WorkerImpl( … | |
| I need Subversion server for eclipse and client which works on Mac, I need something free or a 30 day trial Do you have some idea? Thanks |
Its just a simple question , but i m totally confused that why php and asp hosting are cheaper then jsp. Also what jsp provide which are not provided by php and asp? Thank you in advance for your kind replies. | |
So I'm using OpenGL for a game in java, but I'm stuck on an extremely confusing problem. Class: private class TitleBuilding { private double x1, y1, x2, y2; private double percentage, randValue=1; private byte windowType, numBuildings; private Random random2; private byte index; public TitleBuilding(double percentage,byte numBuildings,byte index) { this.percentage=percentage*.01; this.numBuildings=numBuildings; … | |
Hey so this is my code for checking for palindromes...it compiles fine, the problem is it doesnt work. Basically I converted the four sentences into strings without spaces or other characters and added them to a new string called newstr....i used the newstr to check for a palindrome in the … | |
How to convert a plain text file into a **charsequence** object? | |
I'm trying to write a method that displays the contents of a hashmap on screen. This hashmap contains Strings and an array of int for every String. I've put the String aspects of the hashmap into an arraylist and I'm trying to use another method to print the arrays for … | |
Ok, to be frank... I've just started java yesterday... after few months playing with web application programming (php/js) ... today... I'm building the most simple programming using java .. which is .. login system... username and password... Ok, to make it more usefull... eventho it is simple... I would like … | |
// This is the error message I'm getting..C:\Program Files\Java\jdk1.6.0_25\bin>javac c:\java\Grade1.java // c:\java\Grade1.java:49: variable grades might not have been initialized // switch(grades) // ^ import java.util.Scanner; import java.text.*; import javax.swing.*; import java.util.*; import java.io.*; public class Grade1 { public static void main (String[] args) { String str, lgrade, studentName, courseName; int … | |
I have installed oracle10g but I cannot find any java sample programs for data mining! I could not find any download link on the internet! Please help! | |
Hi, I got an image with 2 colors, black (background) & white (text color), text is "A B C D" I have extracted the white pixels locations, & now I want to figure out the alphabets that are written in this image. Kind of like a screen reader does. I … | |
I am creating an program that allows a user to register for a conference. When I press the "Run" button in Netbeans I get a message saying "Build Successful," but the program does not show up on the screen. What am I missing in my code? I am new to … | |
Greetings All, I have a brain fart. I am trying to print the first and second number in the array which is [0] and [1]. I have the for loop going through each element in the array integersCount[] so I can find those positions. But do I need an if … | |
| I just started learning Java (Currently, I know basic swing components like JPanels, text areas, textfields etc) and I have chosen a Logic Circuit Simulator as a project. My objective is to simulate the working of logic gates by making circuits using drag & drop. So far, I have thought … |
The End.