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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:02:16+00:00 2026-05-26T02:02:16+00:00

I am translating a Javascript function to Java, and I am having troubles with

  • 0

I am translating a Javascript function to Java, and I am having troubles with this text variable below, how to declare and use it in Java:

Javascript:

var text={}; // Index will be several arrays, and value an integer
var word; // Will contain several chars, like a string
var myChar; // Will contain only one char
var value; // Will contain one integer
[...]
if(text[word+myChar]!=null)
{ // In this comparison, word is "hell", myChar is "o" and value is 1234
  text[word+myChar]=value; 
}

Thanks for your help

  • 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-26T02:02:16+00:00Added an answer on May 26, 2026 at 2:02 am

    It would be very helpful if we can see what you have tried so far (in Java). This can help us put into context better what you’re trying to accomplish.

    Here are my tips from what I can gather:

    1. It appears you’re creating a mapping of strings -> integers (or something like that). This would be clearly represented by a HashMap<K,V> in Java. This will say “Map an instance of a value of type V to a key of type K” where K and V can be decided by you. With this, you could create an instance of a HashMap<String, Integer> where you could get/set integer values within the hash map at particular string key.
    2. You could use string concatenation (I assume that’s the operation occurring when you use word + myChar in JS) in a similar manner in Java. You would form a single String object from this.
    3. With a HashMap, you may want to use containsKey(K key) or get(K key) depending on whether you want to see if the key exists in the map at all, or if the value at that key in the map is non-null. This will depend on the context of the problem and what you want to accomplish.

    Here’s a quick (not tested) example of what it may look like:

    import java.util.*;
    
    public class WordIntMap {
        public static void main(String[] args) {
            HashMap<String, Integer> text = new HashMap<String, Integer>();
            String word = "hell";
            char myChar = 'o';
            int value = 1234;
    
            String key = word + myChar;
    
            if (text.get(key) != null) {
                text.put(key, value);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble translating my working C# regular expression into JavaScript's regular expression
I'm currently translating an API from C# to Java which has a network component.
I found a wonderful open source Java program that I'm translating into C#. The
My question pertains to multi-threading in Java. I'm translating an app I wrote in
I'm translating a JavaScript algorithm into PHP, and I ran into the symbol >>,
First of all I alwyas use one #ID. just asking this question to know
I have a PHP application that makes extensive use of Javascript on the client
I'll be implementing this for Node.js (server side Javascript), but this question is about
When I use document.getElementById in Internet Explorer I get this error: Mensaje: El objeto
I read that javascript is JSON in other SO posts. I am having difficulty

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.