Here's a solution that does the following:
- it starts a new file,
\jobname.exs, that stores the titles of your examples; this uses the command \@starttoc
it creates a new environment, example, that can be used either as
\begin{example}{goes into the list of examples}
\lipsum[1]
\end{example}
in which case the argument is written to the \jobname.exs file; alternatively, you can use
\begin{example}[optional caption]{goes into the list of examples}
\lipsum[1]
\end{example}
in which case the optional caption will be written to \jobname.exs
You requested that no packages be used, so I have used a simple list environment to help with the definition of the look of the example environment (see Definitive guide to trivlists) and you'll notice that there is a check to see if #1 is empty, using \ifx\\#1\\ as detailed in Check for empty macro argument and the links within.
The example environment could easily be tweaked if you change your mind later and want to load a package to help with it, e.g ntheorem, amsthm, mdframed, tcolorbox, etc, but for the moment, here's how it looks:

Here's the complete code - compile it twice with pdflatex, or otherwise just run it once with arara which does the double compilation for you.
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage{lipsum}% just to generate text
% this sets up \jobname.exs which will store the
% contentslines added on each example or examples
\makeatletter
\newcommand\listexamplename{List of Examples}
\newcommand\listofexamples{%
\section*{\listexamplename}\@starttoc{exs}}
\makeatother
\newcounter{example}
\newenvironment{example}[2][]{\refstepcounter{example}%
\ifx\\#1\\ % if #1 is empty
\addcontentsline{exs}{subsection}{\theexample~#2}%
\else
\addcontentsline{exs}{subsection}{\theexample~#1}%
\fi
\begin{list}{}{% options
\setlength{\leftmargin}{0mm}% leftmargin
\parsep\parskip% space between paragraphs within an item
\setlength{\itemsep}{-\parsep}% space between items
}
\item {\bfseries Example \theexample: ~#2}
\item}{\end{list}}
\begin{document}
\begin{example}{goes into the list of examples}
\lipsum[1]
\end{example}
\begin{example}[optional caption]{goes into the list of examples}
\lipsum[1]
\end{example}
\appendix
\listofexamples
\end{document}