32,204 Topics
| |
[CODE]private List list(int... ints) { List result = new ArrayList(); for (int i : ints) { result.add(i); } return result; }[/CODE] I got this method from one of my friends and wondered what it does? I have never seen int... ints construct before but am assuming it is an array … | |
Hello Coders out there... I posted my code for a binary search tree assignment and the code is a working code... :::::DETAILS TO KNOW ABOUT THE CODE:::::: the program is required to 1. ask user the HEIGHT OF THE TREE which will determine the length of the array.. 2.and then … | |
i m creating a Client/Server application in which my server and client can be on the same or on different machines but both are under ISP. [B]My RMI programs[/B]:- -Remote Interface:- [CODE]//Calculator.java public interface Calculator extends java.rmi.Remote { public long add(long a, long b) throws java.rmi.RemoteException; public long sub(long a, … | |
Hi everybody..................... how to read a unicode characters (arabic characters) form ResultSet object which appears after extraction as question marks like this(?????) ................. I want to display the fetched UNICODE word from the database and display it in JTextArea............... but getting the same output..............[??????] If anyone knows method to display … | |
I'm looking for a package that can convert a phone number to its country code i know how to write it myself but beter to check the net first anybody ever heard of something like this? eg: 0032586987 > Belgium please give me a link it would save me enormous … | |
Aight. I have a query regarding File I/O : [CODE]// Keep reading the file in a loop for some 100 seconds.. for (int x=0; x<100; x++) { // Code for reading file - say readFile() Thread.currentThread().sleep(1000); /* sleep for one second */ }[/CODE] Now, I need to read a file … | |
hi, i am looking for simple method to copy more than 2/3 arrays into one array.. so far i just learn to copy only two arrays at a time.. [CODE]String[][] data=new String [10][]; String[] column={"Name", "Age", "Sex"}; String[][] first={{"Calvin", "male", "23"}, {"Kathy","female","21"}}; String[][] second={{"Ravi","male","26"},{"Jesan","male","25"}}; String[][] third={{"Jacky", "male", "32"}, {"Jami","female", "23"}}; … | |
[CODE]client.java:18803: orphaned case case 130: // Clicking some stuff in game ^ client.java:24856: illegal start of expression private int somejunk; ^ client.java:24948: illegal start of expression public int EssenceMineX[] = { 2893, 2921, 2911, 2926, 2899}; ^ client.java:24949: illegal start of expression public int EssenceMineY[] = { 4846, 4846, 4832, … | |
Hi, I'm having trouble with...I don't know, either choosing the correct loop to use or maybe using the one I need but having it incorrectly placed. Right now, the program will give the "Invalid item number" message from my else statement if I enter an invalid value in the first … | |
Hi, I've been working on this program for nearly two days straight and I just can't get it quite right. So it's supposed to get input from the user and apply it to a switch statement. There are 5 cases that represent the cost per item for each case. Then … | |
I have my calculator GUI to display as I want it too. When I put in my mortgage amount and choose an option from the drop down box and hit calculate everything works as it should but when I try to manually put in the terms and interest rate and … | |
Hi all, I'm working on a Hanjie solver and this is part of the code. Everything else seems okay but I always get an error when I run it. Eclipse (i'm using Galileo version) points the exception to be at: [CODE] char a = combo1.get(i).charAt(i);[/CODE] combo1 ...refers to a List<String> … | |
So I have junit tests, let's pretend this is my code: [CODE] @Test public void test1() { Object o = new Object("123"); AssertTrue(o.string == "123"); } @Test public void test2() { Object o = new Object("456"); AssertTrue(o.string == "456"); } [/CODE] Let's pretend the code has a public string field … | |
Hi all [CODE]import java.io.*; public class POManager { private static String posFname = "C:/ITM200/OOP-Advanced-Topics/src/po.txt"; private static String taxposFname = "C:/ITM200/OOP-Advanced-Topics/src/tax.txt"; public static void main(String [] args) throws IOException { PO[] pos = readPOFile(); writePOTaxFile(pos); } public static PO[] readPOFile() throws IOException { BufferedReader in = new BufferedReader(new FileReader(posFname)); in.readLine(); String … | |
Hello! I am working through some program to auto-print files to a post script printer via the LPR command. The entire program is running, going through directories, finding the files, then deleting the files. Before deleting the files, though, I added in a section to try and print the files … | |
import java.io.*; import java.util.*; public class Reverseing { public static void main(String[] args) throws Exception { File f = new File("backwards.txt"); Scanner finput = new Scanner(f); String sentence = "", s = "", r = ""; while(finput.hasNext()) { sentence = s + finput.nextLine(); } ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> … | |
Hello I am trying to figure what kind of code that would be needed to add a JTabbedPane to an JInternalFrame. I have 7 tabs added now (as many as I need) they are added by simply adding(hard coded) the "text name" to an array and every time the program … | |
Does anyone know how to put an Image in a Box Layout...just beside the buttons....Pls post me the code if anyone knows it? | |
Hey guys, I am trying to store a varying number of coordinate points in an array. So i thought of a list, and declaring this list as an arraylist using the Point class. Make sense so far? Or am i incorrect already? In doing so i came up with this: … | |
Hi guys, I've hit a problem I'm hoping someone can help me with. I'm trying to create a little irc bot application, just to learn how to use sockets in Java. Everything works fine so far up to the point where I try to pass the data coming from the … | |
I have to write a program using accessors and mutators and a constructor that stores a savings account's annual interest rate and balance. The class constructor needs to accept the amount of the savings account's starting balance. The class needs to have methods for subtracting withdrawals, adding deposits, and adding … | |
hello I'm trying to make a program that allows you to return and calculate the shortest common supersecuence using dynamic programming. The basic ideas of supersecuence common Shortest to search a given set of strings for example L, the smallest chain, which is one for each string supersecuence L. the … | |
we r making an image viewer for our mini project....n we hav tried doing it on our own ..but we are able to show only 1 image ...how to show many images using say 10 images in database?? we want functionalities like easy preview of next / previous image from … | |
is there any sample of java topological sort algorithm based on minimal vertex method. I also need to implement the ADT graph using adjacency lists representations | |
This particular snippet will display a chessboard in a new frame. Needless to say save it in a file named "chessboard.java". | |
basicallt i want to make a simple quiz...and the quiz contained 20 questions...but i have no idea in looping the question...so can anyone help me? [CODE]import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Random; class Quiz extends JFrame implements ActionListener{ private JButton submit,next; private JTextArea text; private JTextField answer; private JLabel … | |
hello everyone i have created a text editor using java swings, my problem is that sometimes all features are working perfectly and sometimes they are not.... i wrote the entire program in one file and the no. of lines in it are 1770,is this a problem for that kind of … | |
import java.util.*; public class KeywordSearch { Scanner input = new Scanner(new File("keyvalues.txt")); Map<String, Integer> wordCountMap = getCountMap(in); for (String word: wordCountMap.keySet()) { int count = wordCountMap.get(word); while (input.hasNextLine()) { line = input.nextLine(); numLine++; Scanner word = new Scanner(line); while (word.hasNext()){ String nextWord = word.next(); numWord++; numChar = numChar + nextWord.length(); … | |
import java.util.*; public class Dice { public static void main(String[] args) { String strInput; Scanner console = new Scanner(System.in); System.out.print(" Please enter desired sum: "); do { Random r = new Random(); int count = 0; int dice1 = 0; int dice2 = 0; a = random number; b = … | |
Hi everyone, I am doing a program here to ask question about alphabet, and i am only in the middle of it and i face some problem that i really cant solve, need some help here... ok the problem is, for(int j =0; j<20;j++), in output, the 1st jlabel.setText(j) is … |
The End.