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 8979513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:51:52+00:00 2026-06-15T19:51:52+00:00

I am doing one exercise in Absolute Java. The Question is : Write a

  • 0

I am doing one exercise in Absolute Java.
The Question is: Write a static method that has a partially filled array of characters as a formal parameter and that deletes all repeated letters from the array. The method should have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. When the letter is deleted, the remaining letters are moved one position to fill in the gap.

What I think of is using hashset, it should be the most easiest way.
And another way that I am thinking is converting array to list , deleting the duplicates element and then transfer it back.
Here is a problem for me: how to write that code?? (why I am asking it?)

public static char[] deleteRepeats(char[] array, int size)
{
    ArrayList<String> newarray = new ArrayList<String>();
    newarray = Arrays.asList(array);
}

it says type mismatching, how can I correct the code?

Another question is: Back to the initial question, how to use partially filled array to implement it?

  • 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-15T19:51:53+00:00Added an answer on June 15, 2026 at 7:51 pm
    ArrayList<String> newarray = new ArrayList<String>();
    

    Is an array list of Generic type String. However your parameters are of char type. Therefore they are not interchangeable. That’s whats throwing the Type Mismatch error.

    You are right using a Set is the easiest way to implement it. However I don’t know whether the exercise wants you to manually do the work.

    However you if you cannot use the wrapper class Character and must use the char type then you must do manual conversion if you are going to get a Set to do your replacement work for you.

    EDIT:

    You cannot use Arrays.asList() method to get a list like that. That method takes java objects as arguments not primitive types. And when you pass the char[] the only object it sees is the array itself.

    So the result is a List<char[]> since generics do not support primitive types.

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

Sidebar

Related Questions

I am doing one exercise in the Absolute Java, Chapter 5, exercise 3. And
I am doing currently a sample exercise and i found one weird observation that
I am doing a book exercise regarding the Ackermann function. I have one question
I am doing one project on Struts 2 that I am getting knowledge little
I'm writing an iOS applications that saves Music albums(just an exercise I'm doing for
I'm doing an school exercise and I can't figure how to do one thing.
Im doing a small exercise to read a file which contains one long string
I am doing some exercises so that I can get through recursive stuff. One
Iam doing one application in iphone.In this i need to get the browsing history
I'm doing one research on video encoding tools for flv. I tested flvtool2 and

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.