LIST class provides you the get method, but there is no get method in SET. As SET is an unordered collection, it is not certain to get the correct element in correct index.
The solution to this problem is, Cast the SET to LIST.
SET<String> str = new Set<String>();
str.add('4');
str.add('1');
str.add('2');
str.add('3');
string f = (new list<string>(str) )[0];
string s = (new list<string>(str) )[1];
You can get the element by index by this way.
Hope this helps!
Check out Salesforce Certification here.
Thanks!