Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:20:16+00:00 2026-06-13T14:20:16+00:00

How do I perform the perfectShuffle operation to my deck array? I do not

  • 0

How do I perform the perfectShuffle operation to my “deck” array?

I do not know how to import the “deck” array into my perfectShuffle method/class (idk wtf is the difference)

This Does NOT compile because my perfectShuffle cant find ”deck”

I’m pretty sure you’re gonna look at my code and be like ‘wtf do u even know what you’re doing?’ well no I dont know what i’m doing but ive gotten super far with not knowing what im doing by creating a deck array of every card in a deck of cards.

Im struggling to find the flow from class/method/object/instance watever and how they interact.

Any help or points to resources is greatly appreciated.

public String[] Deck(){
    String[] deck = new String[52];

    //Populate Deck 2-10
    for (int i=0; i<52; i++){
        if (i<9){
            for (int j=2; j<=10; j++){
                deck[i]=(j+" of Clubs");
                i++;
            }
        }
        if (12<i&&i<22){
            for (int j=2; j<=10; j++){
                deck[i]=(j+" of Diamonds");
                i++;
            }
        }
        if (25<i&&i<35){
            for (int j=2; j<=10; j++){
                deck[i]=(j+" of Hearts");
                i++;
            }
        }
        if (38<i&&i<48){
            for (int j=2; j<=10; j++){
                deck[i]=(j+" of Spades");
                i++;
            }
        }
        else {
            deck[9]=("Jack of Clubs");
            deck[10]=("Queen of Clubs");
            deck[11]=("King of Clubs");
            deck[12]=("Ace of Clubs");

            deck[22]=("Jack of Diamonds");
            deck[23]=("Queen of Diamonds");
            deck[24]=("King of Diamonds");
            deck[25]=("Ace of Diamonds");

            deck[35]=("Jack of Hearts");
            deck[36]=("Queen of Hearts");
            deck[37]=("King of Hearts");
            deck[38]=("Ace of Hearts");

            deck[48]=("Jack of Spades");
            deck[49]=("Queen of Spades");
            deck[50]=("King of Spades");
            deck[51]=("Ace of Spades");
        }
    }
}
private void perfectShuffle(){
    Deck();
    for (int i=0; i<27; i++){
        deck[i]=deck[i+26];
    }
    for (int i=0; i<52; i++){
        System.out.println(deck[i]);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:20:17+00:00Added an answer on June 13, 2026 at 2:20 pm

    perfectShuffle does not have access to the local variables locked away inside of Deck(). You need to grab the value that Deck returns, and make good use of it:

    private void perfectShuffle(){
        String[] myDeck = Deck();
        for (int i=0; i<27; i++){
            myDeck[i]=myDeck[i+26];
        }
        for (int i=0; i<52; i++){
            System.out.println(myDeck[i]);
        }
    }
    

    Likewise, you need to make Deck() actually return that string array, as you have declared the method to return a String[]:

    public String[] Deck(){
        String[] deck = new String[52];
    
        //Populate Deck 2-10
        for (int i=0; i<52; i++){
            // blah blah blah
        }
    
        return deck;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to perform this.Controls.Add(MyObject) in the class definition of MyObject like public MyClass(container/*?*/
I need to perform this operation many times on my data: public void AddBehavior(BehaviorTypes
I perform this kind of query in my Python code to conn = rdbms.connect(instance=_INSTANCE_NAME,
I perform and insert new record, this code below works for for inserting. After
Both perform the same operation that is MSDN Singleton: Single Call objects service one
I would like to perform some request in mysql that i know will be
I would like to perform the same operation on several arrays, something like: #include<vector>
I need to perform some calculations a large list of numbers. Do array.array or
I have to perform some inserts into an Oracle DB. I have some dates
I perform some decoding process in the native code and call a Java method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.