0

I am trying to save two strings and a string array together in one package to an internal storage. But I am having an issue actually combining the three together as one. Here is my code:

class Save_Constructor extends Phone_Save{

String constructor_file_name;
String constructor_class_name;
String[] constructor_notes_to_attach;

    Save_Constructor(){
        constructor_file_name = file_name; constructor_class_name=name; constructor_notes_to_attach=text;


    }

    }

Ideally, I would like to compress these three elements into one, and return them back to the Phone_Save class to be saved into the Phones internal storage. Does anybody have an idea as to how to do this? Honestly I am not even sure whether or not to use a constructor for this, so I am open for any and all ideas. Thanks!

Ethan
  • 225
  • 2
  • 13
  • Check my answer. If you want me to do a demo for you them please explain a bit more about your requirement. Plus accept my answer if you find it useful. – shivamDev31 Jan 24 '15 at 23:16

2 Answers2

3

Just have a look at Java POJO/Bean class and try to understand it in detail. That is the solution for your problem. Just user setters and getters in your class and the use that Class's object as a single entity for your 3 different entities.

Just a quick google search and I got this for you.

Comment below if you dont understand anything.

Community
  • 1
  • 1
shivamDev31
  • 469
  • 1
  • 8
  • 23
  • Thank you for your answer. I have been doing some research for a tutorial on how to create a pojo, but I haven't been able to find a solid one. I am also split whether or not I should even create a POJO as opposed to a Bean Class. If my user input is the same three fields all the time should I create a Bean Class? Because my impression of a bean is that it is set to receive the same variables all the time.Any ideas? – Ethan Jan 25 '15 at 00:56
  • You can use a POJO class and the pass in the values through a constructor and set those values to the constructor. Else you can use a Bean class and use setters and getters and set and get the required values. Sorry didnt understand your user input same case. Could you please elaborate on the same? – shivamDev31 Jan 25 '15 at 10:28
  • I think I have figured everything out. Thank you for all of your help. – Ethan Jan 25 '15 at 18:52
0

Have a look at StringTokenizer Class. You have two ways to approach this. Either you put all the data into one String or into the StringArray. Iterate with for loop to put all this together and then call your store mothod.

BuckRogers
  • 13
  • 5