- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 25
- Posts with Upvotes
- 23
- Upvoting Members
- 18
- Downvotes Received
- 7
- Posts with Downvotes
- 6
- Downvoting Members
- 4
98 Posted Topics
Re: Excuse ztini's rudeness, but I think what s/he meant to say was that we aren't going to solve a problem for you u need to show effort and then we can help you out. However, if you are at a loss as to where to turn, you might want to … | |
Re: Out of curiosity, what sorting algorithm does the Collections class' sort method use? | |
Re: Why can't the farm class create a new Chick object with the syntax Chick(true) or Chick(false) depending on if it is young or old? And you can also add a randomizer if you wanted to, and add isYoung() and isOld() methods. And why can't you add that method to the … ![]() | |
Re: I remember browsing through the API and finding a Robot class and it looked cool so I clicked on it and I was amazed that there was an object that let you control the mouse movement on the screen xD So much crazy stuff to do with the API ^^ | |
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 … | |
Re: @einjelle: you have your math wrong. The program is right. Multiplication is evaluated prior to addition and subtraction, so 5 + 3 * 8 - 4 becomes 5 + 24 - 4 which is equal to 25, not 17. For the next one, division and multiplication again come before addition, … | |
Re: Take a look at the free program Installer Creator -- it lets you set up an install wizard for your program and makes it appear to be exe-ish (an icon shows up in your start menu and on ur desktop etc that you can double click that will link to … | |
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 … | |
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 … | |
![]() | Re: Can you be a little more specific...? Maybe post some of your code here? |
Re: Actually you can just use the System class' arraycopy method, which is designed specifically for this purpose. Check it out in the java api -- the documentation for the arraycopy method is pretty straightforward but if you have any questions with it don't be afraid to ask :) Iterating over … | |
Re: Jeez guys you could give mango a lil' more help than that. S/he clearly isn't playing mp3 files for a school project or something so it's for personal edification -- just give a lil' more guidance... Personally, I've always wondered how to play mp3 files but I have yet to … | |
Re: The problem seems to be in your constructor -- it looks like you are missing the code that initializes the instance variables of the class to the variables passed into the constructor. | |
Re: Here's a very simple example of recursion to help you get started with understanding it: Problem: Write a program to add all the numbers from 1 to X. Solution: [CODE] public static int addFrom1(int x) { if (x<1) return 0; else if (x==1) return 1; else return x + addFrom1(x-1); … | |
Re: I have no idea how what e-man suggested will work at all... Here's what I would do: [CODE] print "Enter series of numbers to calculate the average. Enter 0 to end." while exit is false: Prompt user for #. if # is 0, set exit to true. otherwise, add that … | |
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 … | |
Re: First off if the number has already been placed in the array, you want the user to pick a different number. Right now let's say my set is [4,0,0,0,0] after the first time thru and then I want to put in another 4 for the 2nd slot, the computer will … | |
Re: On line 7 you set the size to int[4], meaning you are using indexes 0-3. In your loop you try to access index 4, which does not exist. To fix this, change line 7 to: [CODE] int numbers[] = new int[5]; [/CODE] | |
Re: XD the problem actually is not in the snippet of code you posted here. You are printing the contents of the Array, namely, the three Punt objects. But it doesn't know how to print a "Punt object" so it is printing the memory address of the objects. If you go … | |
Re: [CODE] import java.util.Scanner; //Same as "include" statement //Lets you use a Scanner object to get input. public class Add2 //Creates a new program named "Add2" { //This is what is inside the program. public static void main(String[] args) //Where the code starts (same as "int main()") { //Begins the "main" … | |
Re: [B][U]Arrays[/U][/B] [INDENT]To create an array use the following general syntax: [ICODE]dataType[] arrayName = new dataType[arraySize];[/ICODE] Accessing Size: [ICODE]arr.length[/ICODE] Accessing Data: [ICODE]arr[index][/ICODE] Modifying Data: [ICODE]arr[index] = var[/ICODE] Insertion: Not Applicable Deletion: Not Applicable [/INDENT] [B][U]ArrayLists[/U][/B] [INDENT]To create an ArrayList use the following general syntax: [ICODE]ArrayList<DataType> arrayName = new ArrayList<DataType>();[/ICODE] Accessing Size: … | |
Re: Imagine a simple branch structure: [CODE] | / \ | | / \ \ [/CODE] The number of leaves for the top part will be the total number of leaves on the left + the total number of leaves on the right. [INDENT]On the left there is again a branch, … | |
Re: Ok I'm not going to tell you what to do, but here's what's happening with the code you provided: You start off with p set to 1. p % 2 does equal 1, so the first time thru, p = p * i, where i is 1. p = 1 … | |
Re: Rofl at least he's being rly honest and straightforward about what he's asking for ;) We definitely want to help you out, but we want you to first try it out yourself. If you get stuck, post your issue and code here and we'll help -- but we want to … | |
Re: You should work from the highest amount of money down. If the highest form of change is 100s, then first check how many 100s are in the number. Then however many there are, subtract it from the number. i.e. if you have $532 you will end with 5 hundreds, and … | |
Re: [CODE] Loop: >> Read in string from user >> Check length of string >> If length == 5: >> Parse the integer from the string (if you're dealing with integers) >> Exit loop [/CODE] Above is the pseudocode for how I would approach the problem. If you use a loop, … | |
Re: The problem is in this line [ICODE]for(x=0;x<sample.length();x++)[/ICODE]. First of all, in order to access the size of an array, you need to call .length without the () afterward. However, even if you modified the line to read [ICODE]for(x=0;x<sample.length;x++)[/ICODE], your code would still be flawed, because the sample array may be … | |
Hey guys~! I am working on a code and I am having some difficulties with it -- Basically I have a 3x3 grid of JButtons that represent the squares on a TicTacToe grid. The code seems to run fine but then after it determines a victor it crashes and says … | |
Re: I would imagine that a "regular variable" is probably just a single variable that doesn't hold an object or array -- it just holds a primitive. But I'm not sure about that. An element is the item that is contained at a certain index in an array. For instance, let's … | |
Re: If you made a Student class, then you can create a student with the syntax [ICODE]private Student[] roster;[/ICODE]. But only if you already made a Student class. | |
Hi guys~! Consider the following code: [CODE=Java] public void reset(int[] arr) { for (int i=0;i<arr.length;i++) { arr[i]=0; } } [/CODE] I know that regardless of what the actual array is before this method is called it will not change afterward because the method cannot modify it since it is not … | |
Re: Learn about Object Oriented Programming and then tackle this program with a Driver and Object. When people shift from non-OOP to OOP they often are used to placing everything inside the main() method. Study OOP a bit more and the proper code for this should become apparent; for instance, you … | |
Re: It seems to me like your problem is in your main method in your first post... I haven't read through your other classes but the way you are getting info from the user is as follows: [CODE=Java] for (count = 0; count < 5; count++) { //get temporary info from … | |
Re: Use code tags -- it makes reading your code easier for ppl so they can help you with the problem. Also, the long else-if series is not very effective coding -- instead you could have made 2 arrays of strings with names for the tens digits and names for the … | |
Re: [ICODE][COLOR="Red"]Pointer type[/COLOR] pointerName = new [COLOR="Green"]Object of that type[/COLOR]();[/ICODE] Consider the code [ICODE]rectangle r1 = new rectangle();[/ICODE]. This creates a new rectangle object and stores it in the computer's memory. It then creates a new pointer, r1, that points to that memory slot: r1 ------> [rectangle() created] [ICODE]rectangle r2=r1;[/ICODE] basically … | |
Re: use code tags to make your code more readable, then people will be more interested in looking through your code. | |
Re: idk how graceful try-catch blocks are but those should do the trick when coupled with System.exit(0)... | |
Re: the main problem is that you are assuming that the syntax for arraylists and arrays are the same. In fact, they are not. Here is a basic table I made that details the differences in syntax: [B][U]Arrays[/U][/B] Accessing Size = arr.length Accessing Data -- arr[index] Modifying Data -- arr[index] = … | |
Re: put the code in code tags and describe what the error is -- that will help ppl know what they are looking for. | |
Re: Write a method that accepts an integer (the grade) and then uses a mathematical calculation to return the grade point. It's your job to figure it out though. But are you supposed to use Java to do your assignment? Because "cout" and "cin" are in C and C++, not in … | |
Re: You're very close :P [CODE=Java] //This method returns the index of the smallest value in the array of given size public static void smallestIndex (int[] array) { int currentValue = array[0]; int smallestIndex = 0; for (int j=1; j < arrSize; j++) { if (array[j] < currentValue) { currentValue = … | |
Re: Lines 8 and 34 have unnecessary braces. There is no need for { or } in those locations. You should create a for-loop after declaring the array that prompts the user to enter an integer as the grade and then stores the integer in the array, and it should loop … | |
Re: When you create PlayingCard objects in HiLo then you are using your other code... is that what you mean? Like if in HiLo you say [ICODE]PlayingCard pc = new PlayingCard();[/ICODE] Then you can call all the PlayingCard methods from the pc object -- pc.drawCard(), pc.getSuit(), etc. are all valid calls … | |
Re: Nothing... if you are wondering why you can't create an object from this code it's because you declared it as abstract. Otherwise it seems fine to me... | |
Re: [CODE=Java] public class array1 { public static void main(String[] args) { int[] gradeArray = {80,90,91,92,93,94,95,96,97,98}; //creates a new array called "gradeArray" that stores grades in it { System.out.println("gradeArray/10"); //literally prints out the words "gradeArray/10" } { System.out.println("lowest grade"); //literally prints out the words "lowest grade" } { System.out.println("Highest grade"); //literally … | |
Re: Ok -- this is what you should do: Create a Java program called FindThatNumber.java. The program should generate 10 random integers between 1 and 100 (inclusive) using Math.pow( ) and then store them sequentially in an array. The program should then ask the user to enter a single integer. If … | |
Re: I agree with BJSJC, but I also realize that by posting here the thread will remain unclosed. So now that I have interjected my opinion, you may kill the thread :) |
The End.