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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:54:10+00:00 2026-05-29T12:54:10+00:00

I have an app where a property file contains data in the following format

  • 0

I have an app where a property file contains data in the following format

name=abc#$#String
age=23#$#Integer

When the value is casted, cast it to values after #$#. is it possible to do this without using a switch or if then else statement.

What I would like to do is have a way to convert the string String or Integer to objects and be able to cast the value without using an if then else block. Something of this sort

String[] tmp = props.getProperty("name").split("#$#");
String name = (tmp[1])tmp[0];
  • 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-29T12:54:17+00:00Added an answer on May 29, 2026 at 12:54 pm

    First of all, you can’t cast a String object to an Integer object; String is not a subclass of Integer. You can, however, convert a String literal into an object and cast something to it:

    Class.forName("some.package.name.SomeClass").cast(aSubclass);
    

    However, the above still applies. You won’t be able to cast “23”, a String, into an Integer.

    It looks like you’re over thinking this a bit. This could be as simple as an if else statement, or perhaps a Factory method, which would eventually do the same thing anyways.

    Also, I would assume that you know the object type before hand, as you’re not going to map name to an Integer in the first place. In which case, you might as well do what alexandros said.

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

Sidebar

Related Questions

I have a main .xib file that contains an App Delegate, Window, and View
I have an ICEfaces web app which contains a component with a property linked
On my app delegate class I have a simple property @property (strong, nonatomic) LoginAppDelegate
I am hosting Python in a SL app. Basically i have an attached property
I have a model in App Engine that I am exporting in CSV format
I have a nib (winA.xib) that contains a window. My app delegate contains an
I have the following set of code in my App.xaml: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary
I have a NSMutableArray in my app which I initiate like this: H-FILE NSMutableArray
I have a xib-file with a small UIView on it, which in turn contains
I have an HTML file that I am loading into a JTextPane which contains

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.