Title: how to get the variable attribute of different activities/fragments with same variable name?
Tags: java;android;variables;if-statement;static
Question: But if I got different activities/fragments with same variable name like:
FragmentA.java:
public static int cat_id = 1;
...
public static int getCategory_ID() {
return cat_id;
FragmentB.java:
public static int cat_id = 2;
...
public static int getCategory_ID() {
return cat_id;
Parser.java:
how to get the category_id of each fragments to set them in if statement like:
int k_id = -1;
...
k_id = current.getInt(...);
if (k_id == cat_id) {
do ...
Comment: You should respect Java naming conventions for your variables.

Here is the accepted answer: those are static methods so you can use them by class name
FragmentB.getCategory_ID()
FragmentA.getCategory_ID()
Comment for this answer: I think you can use Factory design pattern for this issue, but you need to change the structure of code use instance method listed of static
Comment for this answer: http://www.avajava.com/tutorials/lessons/factory-pattern.html Factory design pattern example

Here is another answer: You can get them using class name as:
if(k_id==FragmentA.getCategory_ID())
if(k_id==FragmentB.getCategory_ID())
Comment for this answer: that's the problem because i got an if statement and the k_id should be the  cat_id ...
cat_id = FragmentA.cat_id;
cat_id = FragmentB.cat_id;
so how can i overwrite this value of each fragment ...
Comment for this answer: my solution is now :
if (k_id == FragmentA.getCat_ID() || k_id == FragmentB.getCat_ID() || .... )
your OR helps me :D
Comment for this answer: you can do :if (k_id ==FragmentA.cat_id) or if(k_id==FragmentA.cat_id)
Comment for this answer: But you should use the method.. So I have modified my answer.. I overlooked the method in the beginning :)

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:08/15/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><android><variables><if-statement><static>', 'Title': 'how to get the variable attribute of different activities/fragments with same variable name?', 'ViewCount': 34, 'id': 32025685, 'user_AboutMe': None, 'user_AccountId': 6794467.0, 'user_DisplayName': 'AndroidBeginner', 'user_Reputation': 29.0, 'user_Views': 1.0, 'user_id': 5230339.0}}