# Conversion from a "public String" to a normal String

**URL:** <https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355>\
**Category:** Libraries\
**Created:** [April 16, 2019, 4:44pm UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355 "2019-04-16T16:44:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [April 16, 2019, 4:44pm UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/1 "2019-04-16T16:44:06Z")

</div>

I am obtaining a String from the apsync.\*; library. It is very reliable but I have to declare it as a  
public String.

Later I am trying to compare it to a local string and get a True or false.

Here is the code simplified based on the Processing example.

```auto
  import apsync.*;
AP_Sync streamer0;

public String str0 = "CCdCP";
String str1 = str0;
String str2 = "CCCP";
// Tests to see if 'str1' is equal to 'str2'
if (str1.equals(str2) == true) {
  println("Equal"); // They are equal, so this line will print
} else {
  println("Not equal"); // This line will not print
}
I get the error:

Illegal modifier for parameter str0; only final is permitted

What am I doing wrong?
To summarize:
I want to obtain a string from AP SYNC and compare it to a local value such as "25A" or a local string equal to that.
If they are equal , then my code should execute, etc.

Thanks

```

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [April 17, 2019, 3:11am UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/2 "2019-04-17T03:11:06Z")

</div>

Very odd, I can reproduce it using Processing v3.5.3. You should create an issue in Processing Github. I am assuming this is caused by the error checker having a bug. Or I can create it for you. Just let me know.

Kf

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [April 17, 2019, 5:19am UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/3 "2019-04-17T05:19:56Z")

</div>

I guess we found a bug. I have no idea how to make an “issue”.

Please do it for me, and all of us, lets make a better program.  
This is holding my project. How long till someone will fix it, you think?

Thanks  
Mitch

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [April 17, 2019, 7:01am UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/4 "2019-04-17T07:01:50Z")

</div>

actually, that is correct  
as it is to be used in class ( only ), and there it works.  
[https://processing.org/reference/public.html](https://processing.org/reference/public.html)

```auto
class Test{
  public int a = 5;
}

```

while outside

```auto
public int a = 5;

```

always show that error.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [April 17, 2019, 8:12am UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/5 "2019-04-17T08:12:51Z")

</div>

@laptophead ===  
that is not a bug, that is because in your code you are using local variables and modifiers have not any sense in this case, except for final: other modifiers have sense only for class variables which can be accessed (or not) by other classes. Writing as below and the error disappears.

```auto
public String str0 = "CCdCP";

// Tests to see if 'str1' is equal to 'str2'

void setup(){
  
  String str1 = str0;
String str2 = "CCCP";
if (str1.equals(str2) == true) {
  println("Equal"); // They are equal, so this line will print
} else {
  println("Not equal"); // This line will not print
}
}

```

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [April 17, 2019, 3:13pm UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/6 "2019-04-17T15:13:15Z")

</div>

@akenaton Thanks for your input. That makes sense.

@laptophead To explain this a bit more. When you write code in Processing, people use either use the [static approach](https://processing.org/tutorials/overview/) as in your provided example or they can include setup-draw functions to draw a series of frames. Processing tanspilates your code into Java. This includes arranging your code into a class. Your code above will be placed inside the `setup()` function. Hence, the `public` modifier does not apply.

Kf

---

<div class="post-metadata">

**Author:** ![laptophead](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/laptophead/32/2701_2.png) [@laptophead](https://discourse.processing.org/u/laptophead)\
**Post date:** [April 17, 2019, 10:35pm UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/7 "2019-04-17T22:35:19Z")

</div>

Thank you everyone, I decided not to relay on the AP SYNC anymore, and write my own strings, and split them at the other side.

One other problem was that if a public String, was “equal” with a regular string, the “equal” function was not returning a “true”,

Thanks for the feedback.  
Mitch

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [April 18, 2019, 5:52am UTC](https://discourse.processing.org/t/conversion-from-a-public-string-to-a-normal-string/10355/8 "2019-04-18T05:52:04Z")

</div>

> [@laptophead](#):
>
> One other problem was that if a public String, was “equal” with a regular string, the “equal” function was not returning a “true”,

Please provide the code to reproduce.

Kf
