A List is basically an Array.
Whenever you query for data you usually get a List back. The shorthand SObject obj = [SELECT ... FROM ... LIMIT 1];
can be used to get one record back, but error handling is a bit more difficult.
When you are absolutely sure that you will get a record back, the shorthand is fine, but if there is no record, you will get a System.QueryException: List has no rows for assignment to SObject.
This error also directly shows what is going on in the background. At first the query will return a List, but then the automagic bit of Salesforce tries to pick a record from that list to assign it to your SObject variable, and fails.
So, if you are not absolutely sure that you will get one (and exactly one) record from your query, you should always work with a returned List.
List<SObject> objs = [SELECT ... FROM ...];
Now you have a chance to react to whatever the result may be. To make sure you have at least one record, check that:
if (objs.size () > 0) { ... }
This saves you from the dreaded System.QueryException: List has no rows for assignment to SObject.
But your other quest was how to access member variables of a record stored within a List. I can really recommend some reading on how to program Apex for that. But as a quick solution to your problem:
SObject obj = objs[0];
will give you one record out of the List of records.
You could also iterate over all contained records within one List:
for (SObject obj : objs) { ... }
This will give you each record as a single entry in the variable obj
, allowing you to modify all records returned by a query.