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

  • Home
  • SEARCH
  • 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 8475097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:48:11+00:00 2026-06-10T17:48:11+00:00

inttime[] is an array that already holds single-digit integer values. The first for loop

  • 0

inttime[] is an array that already holds single-digit integer values. The first for loop seeks to convert each integer to a binary string and store it to the string array bintime[]. This part works fine, but when I try to run the next for loop, I get an illegal format conversion error.

for(int j = 0; j < inttime.length; j++){
bintime[j] = Integer.toBinaryString(inttime[j]);
}

for(int a = 0; a < bintime.length; a++){
System.out.println(String.format("%04d",bintime[a]));
}

Why is this happening if bintime[] is a String array?

  • 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-10T17:48:12+00:00Added an answer on June 10, 2026 at 5:48 pm

    If the bintime array holds Strings – as you’ve stated and you’re assigning to the array from Integer.toBinaryString – you’ll see an exception from format trying to print the String as int: the %d format expects an int, and not a String.

    If you’re trying to pad the String representation of a base 2 number, then use something like:

    System.out.println(
      String.format("%4s", Integer.toBinaryString(inttime[idx])).replace(' ', '0'));
    

    The 4 in the format string represents the minimum width of the String, shorter strings will be padded with spaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a multidimensional array with just two values : 0 or
My table looks like this. Location Head Id IntTime 1 AMD 1 1 2
how to convert minutes into days hours and minutes in java ( we have
I have two comboBoxes, one that lists the 7 days of the week and
I've just completed my second OOP class, and both my first and second classes
Using SQL Server 2005 I want to generate the table values between the two
Say you have a function that returns an enum: public enum ServerStatus { Down,
First, in tuning a frequency analysis function using the Accelerate framework, the absolute system
I need to call a program from cmd using an array of numbers(mandatory) and
How can I make a function which returns an array? I tried this const

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.