Search:

Type: Posts; User: camel-man

Page 1 of 2 1 2

Search: Search took 0.44 seconds.

  1. Replies
    5
    Views
    76

    Re: Creating new objects within methods

    "blah" in my case is the data type. In your case it would be User. You might want to put User in another class instead of having it in main.


    public class User
    {
    String username;
    String...
  2. Re: if-else statement not working and dont know why

    You have a semicolon after the if statement. You need to remove it.
  3. Replies
    5
    Views
    76

    Re: Creating new objects within methods

    create an arrayList of objects. Then use the constructor for the usernames and passwords.


    ArrayList<blah> t = new ArrayList<blah>();

    t.add(new blah(/*the username , the password*/));

    You...
  4. Replies
    5
    Views
    76

    Re: Creating new objects within methods

    How about prompting the user in main to enter in a username and password. Then use the username and password in the constructor of the object you create.

    example

    enter in username
    //user...
  5. Re: Converting primitive data types to read integers with decimal

    parseInt is for integers. But you are trying to parse a double. Try parseDouble.

    Something like this


    milesPergallon =(int) (Double.parseDouble(milesDriven) / Double.parseDouble(gallonsUsed));
  6. Re: Need help on ideas to approach this String problem..

    public static void main(String[] args) {

    String a = "Hi I am Bob";
    String[] words = a.split(" ");
    String newOne= "";

    for(int i=words.length-1;i>=0;i--)
    {
    newOne+=words[i];...
  7. Need help on ideas to approach this String problem..

    I am not very comfortable with Strings in Java. I have a pretty knowledgeable background in C, and I learned that it is not the way to approach problems in Java with a "C" mindset.

    The problem I...
  8. Thread: BinaryTree

    by camel-man
    Replies
    5
    Views
    134

    Re: BinaryTree

    You need to make your methods static. ex.)static public void readFile(){
    .....
  9. Re: I think one class is over riding the other one?

    For testing purposes, when you run it and you see the frame empty, grab the corner of the frame and stretch it out to a larger size to see if the drawing appears. If it does then I might be able to...
  10. Thread: BinaryTree

    by camel-man
    Replies
    5
    Views
    134

    Re: BinaryTree

    Define " I am having trouble with trying to get the main method to work". What error messages do you get, if any?
  11. Replies
    4
    Views
    142

    [SOLVED] Re: Help with my simple Scanner program?

    Is this due to the newline('\0') being left in the buffer after the user enters in the int?
  12. Replies
    1
    Views
    101

    [SOLVED] Need guidance on adding characters

    Right now I have three stacks. Each stack holds characters, with the normal operations of pushing and popping. I am trying to compare two characters from stack1 and stack2(each character is a digit...
  13. Replies
    3
    Views
    95

    Re: Button not showing on panel?

    Thank you very much sir.
  14. Replies
    3
    Views
    95

    Button not showing on panel?

    I have three classes.. 1. panel class 2. frame class and 3. tester class

    I am creating the objects like so but when I add button to panel then panel to frame I am not seeing the button. here is my...
  15. Replies
    2
    Views
    139

    What is this declaration considered?

    When you say


    int array[];

    I know that this is declaring an array without a size. Does that mean that this is "Sort" of like a pointer. A slot in memory waiting for an address to fill its...
  16. Replies
    1
    Views
    129

    Cannot get rid of File Input error

    import java.util.Scanner;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.PrintWriter;

    public class CountryPopulationReverse{

    ...
  17. Replies
    4
    Views
    186

    Re: why wouldn't it print my code?

    Give an example of your input and what does it output
  18. Replies
    1
    Views
    252

    Re: Home work help?

    What have you done so far? You need to show a valiant effort, write down your outline of the program on paper if you need to get a start on it.
  19. Replies
    3
    Views
    319

    Re: int cannot be dereferenced

    it is referring to the integer being passed into the method, If you want to refer to the queue then you need to add the keyword "this"


    for (int i = 0; i < this.kassas.length; i++)
    {...
  20. Replies
    6
    Views
    312

    Re: Pls me out on this arrays number print

    You have your column and row numbers reversed.

    Columns should equal 6 and rows should equal 3
  21. Replies
    5
    Views
    279

    Re: How to validate user input in a loop

    Right, but I thought that it would then eventually reach the top of the while loop and then go back into the try statement.

    I ended up adding sc.next(); in the catch statement and now all is...
  22. Replies
    5
    Views
    279

    Re: How to validate user input in a loop

    Yes I tried a while loop like this, but whenever I enter in a double for example. It will go into an infinite loop saying "try again wrong type"



    int i=0;
    while(i<3)
    {
    try
    {
    ...
  23. Replies
    5
    Views
    279

    How to validate user input in a loop

    Is there a method that allows me to check if the user entered anything other than an integer. For example I want the user only to enter an integer, I have this code.




    try
    {
    ...
  24. Re: Beginner struggling with homework question

    First off you need to switch around your assignment statements. Your constructors purpose is to set the values of the object to that of the parameters passed to it.
  25. Replies
    6
    Views
    268

    Re: I need help developing an algorithm.

    i thought Java used Unicode?
Results 1 to 25 of 32
Page 1 of 2 1 2