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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:35+00:00 2026-05-20T01:23:35+00:00

Building a multi-language application in Java. Getting an error when inserting String value from

  • 0

Building a multi-language application in Java. Getting an error when inserting String value from R.string resource XML file:

public static final String TTT =  (String) getText(R.string.TTT);

This is the error message:

Error: Cannot make a static reference to the non-static method getText(int) from the type
Context

How is this caused and how can I solve 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-05-20T01:23:36+00:00Added an answer on May 20, 2026 at 1:23 am

    Since getText() is non-static you cannot call it from a static method.

    To understand why, you have to understand the difference between the two.

    Instance (non-static) methods work on objects that are of a particular type (the class). These are created with the new like this:

    SomeClass myObject = new SomeClass();
    

    To call an instance method, you call it on the instance (myObject):

    myObject.getText(...)
    

    However a static method/field can be called only on the type directly, say like this:
    The previous statement is not correct. One can also refer to static fields with an object reference like myObject.staticMethod() but this is discouraged because it does not make it clear that they are class variables.

    ... = SomeClass.final
    

    And the two cannot work together as they operate on different data spaces (instance data and class data)

    Let me try and explain. Consider this class (psuedocode):

    class Test {
         string somedata = "99";
         string getText() { return somedata; } 
         static string TTT = "0";
    }
    

    Now I have the following use case:

    Test item1 = new Test();
     item1.somedata = "200";
    
     Test item2 = new Test();
    
     Test.TTT = "1";
    

    What are the values?

    Well

    in item1 TTT = 1 and somedata = 200
    in item2 TTT = 1 and somedata = 99
    

    In other words, TTT is a datum that is shared by all the instances of the type. So it make no sense to say

    class Test {
             string somedata = "99";
             string getText() { return somedata; } 
      static string TTT = getText(); // error there is is no somedata at this point 
    }
    

    So the question is why is TTT static or why is getText() not static?

    Remove the static and it should get past this error – but without understanding what your type does it’s only a sticking plaster till the next error. What are the requirements of getText() that require it to be non-static?

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

Sidebar

Related Questions

I'm building multi-language support for PHP page. Let's say I have a page url:
I am building a multi-layered application that has an ASP.NET MVC web application. It
I'm building a multilanguage application with MVC 2. I read a lot of posts
I'm building a multi threaded cache in C#, which will hold a list of
If I am building a multi-shop e-commerce solution and want the orders table to
I'm building a simple multi-user (multi-tenant?) App with ASP.NET MVC3 and EF4, one database,
I am currently experimenting with building an http server. The server is multi-threaded by
I am building an IQueryable based on parameters I get from the user. One
I am building a ASP.NET page which is an Sales Order Processing Form I
I'm new to Core Data, and am struggling with some of it conceptually (relative

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.