Question: I have a text file containing data. The data, in this case, are simply the numbers '0.049371 0.049371 0.000000'.

I have the code

```
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt("/path/to/file", delimiter=",")

plt.figure()

plt.plot(range(len(data)), data, color='blue')
plt.xlim(0, 100)
plt.ylim(0, 50)
plt.xlabel('t / t₀', fontstyle = 'italic')
plt.ylabel('Speed', fontstyle = 'italic')

plt.show()

```

But I get the error message 'ValueError: could not convert string to float'. Is there a way to convert all of the values in a text file to floats?

Thank you

Answer: 
Sticking classes in classes makes 'instance classes' which you don't want, usually. They have an extra invisible field of their outer type: You can't make new instances of e.g. `Mysister` here without also having an instance of `savings` available, which you don't. This is all very confusing so you never want to do this until you're much more advanced in java (and even then, I generally avoid it, saving a few characters at the cost of confusing code is rarely a good tradeoff).

Either don't stick classes in classes, or remember to *always* mark classes-in-classes as `static`. Such as `static class MyParent {`.
The [Answer by rzwitserloot](https://stackoverflow.com/a/71785049/642706) is correct.

 The likely solution is to move those related classes to *outside* the `Savings` class.

Also, given your naming, you seem to be confusing the idea of classes with instances. There is no need for `MyInfo` and `MyParent` and `MySister`. The state and behavior of those are all the same. The only difference is their relationship to you. Instead, using a single class `Person`. And, either add a `relationship` member field to the class, or imply the relationship through the naming of instance variables. See code below.

Tip: Define your classes more briefly as a record if their main purpose is to communicate data transparently and immutably.

By the way, watch your naming. Java naming conventions start a class name with an uppercase letter. So `Savings`, not `savings`.

```java
record Person ( String name , int balance ) {}

```

Another tip: A record can be declared locally, within a method. Or declare by nesting in a class. Or declare separately, in its own `.java` file.

Yet another tip: You can use a LOW LINE (underscore) character to arbitrarily group the digits of a numeric literal.

In your `main` method, or other such code, instantiate.

```java
Person me = new Person( "Gaga" , 1_000_000 ) ;
Person parent = new Person( "Abdul" , 20_000_000 ) ;
Person sister = new Person( "Ifdah" , 500_000 ) ;

```

Make a list and loop, to report.

```java
List<Person> persons = List.of( me , parent , sister ) ;
for( Person person : persons ) 
{
    System.out.println( "Name: " + person.name() … ) ;
}

```