Search:

Type: Posts; User: arhzz

Page 1 of 6 1 2 3 4

Search: Search took 0.11 seconds.

  1. Replies
    6
    Views
    696

    Re: Rewriting a method recursivly

    Yea,also a little typo from me.



    public class test {
    public static void main(String[] args) {
    System.out.println(isPower_recursive(2,16));


    }
  2. Replies
    6
    Views
    696

    Re: Rewriting a method recursivly

    I found online how to transform iteration into recursion,followed the guide (its literally a pattern you have to follow).And I solved the problem.For those are interested;



    public static...
  3. Replies
    6
    Views
    696

    Re: Rewriting a method recursivly

    Actually I've solved it already,like this.I dont need to solve it recursivly I want to solve it recursivly.To be precise I want to be able to "transform" iterative code into recursive,to figure out...
  4. Replies
    6
    Views
    696

    Rewriting a method recursivly

    Hello!

    Consider this code



    public static boolean isPower(int x, int n) {

    if (x == 1)
    return (n == 1);
  5. Replies
    2
    Views
    691

    Re: Use char[][] instead of string[].

    If you want to use the word apple as char and not a string you have use ' ' and not " ".
  6. Re: How to find all the words of a certain length in a String and return them.

    Thank you,and also thank you for your help!
  7. Re: How to find all the words of a certain length in a String and return them.

    It worked just fine.Is it not working on your end?
  8. Re: How to find all the words of a certain length in a String and return them.

    Oh okay,I didnt know I could do that.I'd assume this is the way




    import java.util.Arrays;
    public class test {

    public static String[] splitString (String s) {
    return s.split (" ");
  9. Re: How to find all the words of a certain length in a String and return them.

    Getting this error test.java:14: error: cannot find symbol
    return savedWords;
    ^
    symbol: variable savedWords
    location: class test
    1 error
  10. Re: How to find all the words of a certain length in a String and return them.

    But what are my savedWords and what is my newWord? How do I "access" them ?
  11. Re: How to find all the words of a certain length in a String and return them.

    I can return them any way I would like,I'd prefer the easiest solution.
  12. Re: How to find all the words of a certain length in a String and return them.

    import java.util.Arrays;
    public class test {
    public static String[] splitString (String s) {
    return s.split (" ");
    }

    public static void wordsOfLength(String words,int length) {...
  13. Re: How to find all the words of a certain length in a String and return them.

    11 is the count of the chars in the text.

    Well I'm aware that the program,when it entcounters a white space it should register that we have found a word.Not really sure how to do that.
  14. Re: How to find all the words of a certain length in a String and return them.

    import java.util.Arrays;
    public class test {
    public static String wordsOfLength(String words, int length) {
    int cnt = 0;
    String foundWords = "";
    for(int i = 0; i < words.length(); i++) {...
  15. Re: How to find all the words of a certain length in a String and return them.

    So my step by step solution

    1.Read in the text and the length
    2.Go through the text and find the length of the first word(than the second,third...)
    3.Check if the length of the first word is the...
  16. How to find all the words of a certain length in a String and return them.

    Hello!

    What I need to do is given a input of a random text and a certain length,from the user I need to find all of the words in that text that have that length and return them. For example we...
  17. Replies
    6
    Views
    532

    Re: Why does my code always print out true.

    Yea I see it as well, the values of the char are single digit that is why its always printing true.Which means my logic wasnt at fault but the readChar() method.Thank you for your help,I'll adjust...
  18. Replies
    6
    Views
    532

    Re: Why does my code always print out true.

    Okay,very very interesting results;

    for 12;

    12
    ch=49 1
    true

    for 8
  19. Replies
    6
    Views
    532

    Re: Why does my code always print out true.

    At what point in the code do I want to see the value of ch? When the user inputs the value?
  20. Replies
    6
    Views
    532

    Why does my code always print out true.

    Hello!

    Consider this code




    import java.util.Arrays;
    public class test {
  21. Re: Determening the output when dealing with exceptions without running the code

    I'll give it a shot,thanks for the suggestion.
  22. Re: Determening the output when dealing with exceptions without running the code

    I kind of want to avoid doing that,but I guess there is no other way.

    EDIT: Okay so I was right for f(3) and f(12).But for f(0) I was wrong,it should be like this;

    f(0) = c f g

    And I am not...
  23. Re: Determening the output when dealing with exceptions without running the code

    Well I already did that,and I've posted what I think would come out for the diffrent values of x.I've redone the task and I think it should be right. What do you think?
  24. Determening the output when dealing with exceptions without running the code

    Hello !

    Consider this code;




    void f(int x) {
    try {
    g(x);
  25. Replies
    4
    Views
    602

    Re: Diagonal of a matrix usind a 2d int array

    Oh wow,that is embarassing,quite a silly mistake.It works just fine now thank you!
Results 1 to 25 of 147
Page 1 of 6 1 2 3 4