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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:37:33+00:00 2026-05-26T15:37:33+00:00

Hi all i need to typecast a String value into a char . Please

  • 0

Hi all i need to typecast a String value into a char .
Please help me , i am not sure how to do this
This is my code

At First i have a Enum class as shown

public enum RemoteType {
    @XmlEnumValue("Call")
    Call("Call"),
    @XmlEnumValue("Put")
    Put("Put");

    private final String value;

    RemoteType(String v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static RemoteType fromValue(String v) {
        for (RemoteType c: RemoteType.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }

}

This Enum ( RemoteType) is present inside a DTO (FOrmBean ) as shown

public class Subform implements Serializable
{
private RemoteType        remoteType;

  public RemoteType getRemoteType()
   {
      return remoteType;
   }

   public void setRemoteType(RemoteType remoteType)
   {
      this.remoteType = remoteType;
   }
}

I have another class called as MyObject as shown

class MyObject
{
public char side; 
}

For this MyObject side property which is a char i want to assign this remoteType property of FormBean by calling Getter Method on it.

Now I am setting data inside the DTO Form Object as shown

Subform subform = new Subform();

subform.setRemoteType(RemoteType.Put);

After setting the data (IN JSP ) that , Now i am tying to extract it (IN Controller) and assign String to char as shown .

MyObject object = new MyObject();
object.side = Subform.getRemoteType().value(); // How can we assin (Here i am getting errror

saying cant assign string to char)

please help me

( The code is of jar files , so we cant change the Data types )

  • 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-05-26T15:37:34+00:00Added an answer on May 26, 2026 at 3:37 pm

    You can’t cast an entire String to a char, but if your String only has a single character in it, then you can simply do:

    char theChar = myString.charAt(0);
    

    Otherwise, you’ll have to decide on how you can convert that String into a char – maybe you’ll just grab the first/last character in the String, or maybe you’ll perform some algorithm that “sums up” the characters into a single character.
    Either way, there’s no general way for you to turn a String into a char as a String is just a collection of chars.

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

Sidebar

Related Questions

All I need this for is strcpy(). I want to see whether the first
I've been trying to get this code to work for hours! All I need
I have a jpeg image in a char[] buffer in memory, all I need
I have a huge collection of videos that all need to be converted into
Hey all need a lil help sorting a loop for this table out, cant
Let's say I have 10 tableViews that all need to have the first cell's
I have multiple threads who all need to write to the same Dictionary. I
I have multiple threads (C# application running on IIS) running that all need to
I've got a reasonably simple query (this time) that I need ALL the results
I'm not familiar with ADO.NET Data Services but it looks usable. All I need

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.