Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 19 of 19

Thread: biginteger

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default biginteger

    how can i store biginteger in an array?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: biginteger

    Quote Originally Posted by subhradeep View Post
    how can i store biginteger in an array?
    Create an array of type BigInteger, and set each index of the array as appropriate. Suggested reading:
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
    If that doesn't address your question, please be a lot more specific.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    but Array can't store biginteger value

  4. #4
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: biginteger

    Quote Originally Posted by subhradeep View Post
    but Array can't store biginteger value
    Actually it can.
    Just think on how to declare an int array, String array, char array. Then you'll realize how to declare a BigInteger array

  5. #5
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    just like this:
    biginteger[] anArrayOfBigintegers;

  6. #6
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: biginteger

    Quote Originally Posted by subhradeep View Post
    just like this:
    biginteger[] anArrayOfBigintegers;
    yeah you got it.

  7. #7
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    thanks sir

  8. #8
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    import java.math.BigInteger;
    public class Array
    {
    public static void main(String sr[])
    {
    biginteger arr[]={55,15,2,3};

    for(int i=0;i<4;i++)
    {
    System.out.println("list"+arr[i]);
    }
    }
    }


    I can't implement any biginteger array..please help me..

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: biginteger

    Try defining an array of BigIntegers with a size and then assigning to each element in the array an instance of BigInteger.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    import java.math.BigInteger;

    public class Array
    {
    public static void main(String sr[])
    {
    biginteger number[]=new biginteger[2];
    number[0]=new biginteger[3];
    number[1]=new biginteger[2];
    for(int i=0;i<2;i++)
    {
    System.out.println("ARRAY"+number[i]);
    }
    }
    }


    Sorry.. Again I fail to create biginteger array..have any another idea?please send me a correct biginteger array code
    Last edited by subhradeep; April 2nd, 2014 at 11:34 AM.

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: biginteger

    fail to create biginteger array
    Please explain what the problem is.
    If there are error messages, copy the full text of the messages and paste it here.

    Be sure to wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: biginteger

    For future reference, please be explicit when explaining your problem. If you post code, state whether it compiles or define any exceptions and post the full error messages. Further, please wrap all code in the code tags

    import java.math.BigInteger;
    ...
    biginteger number[]=new biginteger[2];

    Java is case sensitive.

  13. #13
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    import java.math.BigInteger;
     
    public class Array
    {
    public static void main(String sr[])
    {
    biginteger number[]=new biginteger[2];
    number[0]=new biginteger[3];
    number[1]=new biginteger[2]; 
    for(int i=0;i<2;i++)
    {
    System.out.println("ARRAY"+number[i]);
    }
    }
    }


    C:\Java\jdk1.5.0\bin>javac Array.java
    Array.java:7: cannot find symbol
    symbol : class biginteger
    location: class Array
    biginteger number[]=new biginteger[2];
    ^
    Array.java:7: cannot find symbol
    symbol : class biginteger
    location: class Array
    biginteger number[]=new biginteger[2];
    ^
    Array.java:8: cannot find symbol
    symbol : class biginteger
    location: class Array
    number[0]=new biginteger[3];
    ^
    Array.java:9: cannot find symbol
    symbol : class biginteger
    location: class Array
    number[1]=new biginteger[2];
    ^
    4 errors

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: biginteger

    Reread the last line in post#12

    Or define your own class named: biginteger that takes an int value in its constructor.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    please give an complete example...

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: biginteger

    You used the correct spelling in the import statement:
    import java.math.BigInteger;
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Mar 2014
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: biginteger

    what is my mistake?I use the correct spelling...

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: biginteger

    Yes the spelling in the import statement is correct.
    The compiler can not find the definition for the biginteger class.
    Where is that class defined?

    Do you understand that 'b' is not the same as 'B'?
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: biginteger

    My .02: if you are having this hard of a time with basic language syntax, I would recommend taking a step back - ignore the BigInteger class for the moment and take some time to learn some of the essential basics of the language:
    The Java™ Tutorials

Similar Threads

  1. Sorting BigInteger Arrays
    By WD3k in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 23rd, 2014, 11:21 PM
  2. How do I convert a char into a BigInteger and vice versa?
    By ineedahero in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 12th, 2013, 09:53 PM
  3. Replies: 10
    Last Post: March 26th, 2013, 04:46 PM
  4. BigInteger.isPrime
    By sci4me in forum Java Theory & Questions
    Replies: 2
    Last Post: March 17th, 2013, 04:33 AM
  5. Euclid Calculator GCD and LCM using BigInteger
    By Exiled in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 18th, 2012, 11:00 PM