Yes! Stack Exchange has always explicitly encouraged users to answer their own questions. If you have a question that you already know the answer to, and you would like to document that knowledge in public so that others (including yourself) can find it later, it's perfectly okay to ask and answer your own question on a Stack Exchange site.
To encourage people to do this, there is a checkbox at the bottom of the page every time you ask a question. If you have more than 15 reputation and already know the answer, click the checkbox that says "Answer your own question" at the bottom of the Ask Question page. Type in your answer, then submit both question and answer together.
Alternatively, you may go back and add an answer to your own question at any time.
You can also accept your own answer, but you must wait 48 hours to do so. After all, someone else may come along with an even better solution to your problem!