Results 1 to 3 of 3
  1. #1
    Dev23 is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default trying to figure out how to minus the place of an int parameter in a method.

    I'm trying to figure out how to solve this particular problem:

    I'm given a limited length of a string number and im trying to figure out how to find a particular char in the string and if not, if the index of this character is greater than this character itself, reduce the index by one and return it into the method until it has found the desired number.

    For example: string d = "23456";

    If 3 (1) was my desired target and the index called from main was a number greater than 3 (1) and less than 6 (4) it would minus that number and return it back to the method to repeat the process until the index 1, is found.
    Last edited by Dev23; 04-17-2011 at 03:35 AM.

  2. #2
    Maximus-EVG is offline Member
    Join Date
    Apr 2011
    Location
    Canada!
    Posts
    30
    Rep Power
    0

    Default

    Here's something to get you started:

    Java Code:
        public static void main(String[] args){
    
            String d = "23456";
            char[] allCharsInString = d.toCharArray();
    
            for (int i = 0; i<allCharsInString.length; i++){
                System.out.println(allCharsInString[i]);
            }
    
    
        }
    With the above piece of code you're now able to examine every character in the string. All you need to now is to find the steps to do what the assignment tells you to do.

  3. #3
    Dev23 is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

Similar Threads

  1. Replies: 18
    Last Post: 04-18-2011, 05:39 AM
  2. Class<T> in method parameter
    By Onra in forum New To Java
    Replies: 4
    Last Post: 03-14-2011, 12:12 AM
  3. Creating array in method parameter
    By Dipke in forum New To Java
    Replies: 2
    Last Post: 02-25-2011, 09:18 AM
  4. Replies: 9
    Last Post: 01-17-2011, 12:14 AM
  5. Can a method take itself as parameter?
    By bukake in forum New To Java
    Replies: 10
    Last Post: 09-06-2008, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •