- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 25
- Posts with Upvotes
- 23
- Upvoting Members
- 18
- Downvotes Received
- 6
- Posts with Downvotes
- 5
- Downvoting Members
- 3
Since I keep seeing people asking how to read the Integers from a File, I figured this simple snippet might be useful. What it does is it creates a new Scanner Object based on the File Object "test.txt" then it reads all of the Integers from that file, skipping over … |
|
I'm doing a lesson that is supposed to demonstrate inheritance using the song Old MacDonald; there's an animal interface, a farm class that implements each animal object.. you get the idea. I've got two problems. First, The animal has a type and a sound, for example, a chick is [code] … |
|
Hello to everyone, I am new to this forum as I am new to Java. I would like to know if anyone has come up with a method that helps in learning the huge collection of classes of the Java API. I know that question is not easy to answer. … |
|
Hey everyone! I was recently introduced to Ruby and am trying to learn it by working my way through the Ruby on Rails 3 Tutorial, but I got a little stuck on autotesting. The guide says that for Windows I should install "Growl for Windows," which I did, and then … |
|
Solves simple string-based expressions. Currently only supports integers, but can easily be expanded to support float-types. |
|
Hello Everyone, i'm trying to convert a .jar file to .exe... first of all is it possible? If so then how? |
|
Hey guys! So I recently started exploring the InetAddress object, and came across 2 methods which confused me: [ICODE]getHostName()[/ICODE] and [ICODE]getCanonicalHostName()[/ICODE]. I don't fully understand the difference between a canonical host name (fqdn) and a general host name, so if someone could explain the distinction to me in detail that … |
|
I have been searching online for a program that will: -reads in number of times a user wants a coin flipped -flip the coin that many times, printing out result of each coin flip -print out the total number of heads flipped and total number of tails flipped the application … |
|
Hi all! In a course I am T.A.ing, one of the students submitted this program as their assignment and I did not fully understand why it wasn't working: [CODE=Java] public class Alphabet { public static void main (String[] args) { char alphabet= 'A'; System.out.println("The following is the English alphabet."); while … |
|
Hey guys! So I was wondering -- what's the syntax for updating a JTable that is being displayed on the screen? I know how to allow cells to be edited, but what if I want to like add in entirely new rows while it's being displayed? I tried repaint() and … |
|
Hey Everyone! I need some help with a JTable I'm working on. [CODE] TableColumn column = table.getColumnModel().getColumn(2); ... JComboBox comboBox = new JComboBox(); comboBox.addItem("A"); comboBox.addItem("B"); comboBox.addItem("C"); comboBox.addItem("D"); comboBox.addItem("E"); comboBox.addItem("F"); column.setCellEditor(new DefaultCellEditor(comboBox)); [/CODE] I know that the code above will take the column of the table at index 2 and give … |
|
|
I want to create a digital clock in Java can any one help me out i am having problems updating the second variable |
Hi, I basically have 1 arrayList with 10 elements. [CODE] //arraylist with10 elements private ArrayList<String> arrayList1 = new ArrayList<String>(); //arraylist with nothing in it. private ArrayList<String> arrayList2 = new ArrayList<String>(); public void copy() { Collections.copy(arrayList1, arrayList2); } //The code above will copy all the elements in the first arraylist to … |
|
Is there anyway to play an mp3 file in java? P.S I'm new here, hello world? |
|
The Vehicle.java is the file that I am modifying. The second code is the testdriver. [CODE]public class Vehicle { String make; String model; int year; public Vehicle(String s1, String s2, int y) { if (y >= 1980 && y<= 2012) { year = y; } else { y = 2010; … |
|
Yeah... I have a headache... So I have the following code: [CODE]public class inc { public static void main (String args[]) { new inc(); } public inc() { System.out.println (addTwo(7)); } public int addTwo(int n) { System.out.println (n); if (n < 1) { return 2; } else { return addTwo(n-1)+2; … |
|
[CODE]import java.util.Scanner; class CalcAvg{ public static void main (String args[]){ Scanner s = new Scanner(System.in); int sum = 0; int avg = 0; for(int i = 0; i < 10; i++){ System.out.println("Enter a number: "); int num = s.nextInt(); sum = sum+num; } avg = sum/10; System.out.println("The sum is: " … |
|
Hey guys I'm working on a program that asks the user to enter a month and year and then prints that month's calendar page on the screen. However, to do this I created a daysBetween() method that accepts 2 dates and finds the number of days between them. So basically … |
|
I'm trying to find a way to search an array to see if the values entered bu the user are already in the array. For example, if numbers[0] = 1, and the user tries to input numbers[1]=1, then I want the program to kick an error back that won't allow … |
|
I can't figure out what the error means that I keep getting on my loop. I have it set to only take 5 arguments, which is my limit, but I can't tell what it's saying: [code] Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at Duplicates.EnterNumbers(Duplicates.java:20) at Duplicates.main(Duplicates.java:28) [/code] Here's my code: … |
|
Hello everybody, This is my first time on this forum. I started this year with a study, where i learn Java. I'm from the Netherlands, so some names in the classes you may not know. I have a problem with printing out a few arrays of P in the class … |
|
Since starting this course and seeking to join this forum, I have learned a lot and want to thank everyone for their assistance on my own forum questions as well as those I have read during research in this forum. Having said that I have another array question. I now … |
|
guys! can you help me convert this code to java language.... this is my code in c++....i need to convert in java.... # include <iostream.h> int num1,num2,sum; double add(double sum); int main() { cout<<"Enter first number"; cin>>num1; cout<<"Enter second number"; cin>>num2; sum=add(sum); cout<<"The sum is: "<< sum; return 0; } … |
|
Hi Guys, i'm new to java and i need a code like a student form or employee on how to add, search, and delete a data in an array or list.. i'm very confused and i really need your help.. thanks. |
|
Hello guys, i'm studying the Java programming language. every thins were going very well, but once i have encountered RECURSION i started to feel so bad. there is a recursive method that is blowing my mind. I can't figure out how does it print that the sum of a set … |
|
Hi, I'm having a difficult time printing the product of the odd integers from 1 - 15. When I run it the program prints "1 2 2 2 2 2 etc." I don't see what I'm missing or why it won't print what I want. Did I add something I … |
|
write a program in diving competitions, each jump is assessed by seven judges who give points on a scale from 0 to 10. The point for each jump are calculated as follows: Ignore the highest and lowest scores given by the judges. Then calculate the average of the remaining five … |
|
Hi, I'm brand new to the forum and am taking an intro to Java class and need tome help. I have never programmed before so go easy on me, lol. The problem is to get the exact change from a dollar amount that a user inputs. Example: $4.23 is 3 … |
|
How can I code to restrict the users input to 5 numbers and no more or less....I can't think of a good way to do it. [code] import java.io.*; public class Palindrome { public static void main(String [] args){ try{ BufferedReader object = new BufferedReader( new InputStreamReader(System.in)); System.out.println("Enter number"); int … |
|
Hello im having problems with my code. i wanted to make a program that would let me enter anything and then place each one of them inside the array. [CODE]import java.util.*; class charAt { public static void main(String[]args) { Scanner input=new Scanner(System.in); String[]sample=new String[52]; String enter; int x; System.out.println("Enter something"); … |