There are many scripts to run an action or other operation on all layers or only selected layers. Some may or may not work with different versions of Photoshop.
To save and use script code:
Copy the code text to the clipboard
Open a new blank file in a plain-text editor (not word-processor)
"if your supposed to copy the java code where you to paste the java code?"
Paste into notepad then save as JSX in Presets > Scripts folder. Restart Photoshop and script should appear in File > Scripts. Otherwise save script anywhre then use File > Scripts > Browse and navigate to script.
"Is this the only way to apply an action on mutliple layers by the way?"
Yes, there isn't built in option. You can run action on each and every layer or to try with Conditional actions but that is complex. The problem is that you can not tell through condition to not apply action twice to the same layer so you must have exact or matching number of conditional steps. Another option is to go through layers and apply same steps but again you must have matching number of select next layer and layers in the Layers panel.
I've been using the new version since it became available, because it is so much better. When you use the older Shift F5 (Fill) dialog and choose Content Aware the toolbar switches to the Sample tool regardless of what was already selected. This _appears_ to give you the option to Sample All Layers, but if you check my screenshot below where I have an empty layer selected...
...you get this error message
The exact same process but with the half filleed yellow layer selected ignores the underlying layer
I don't know if that answers your question in whatever context you were asking it from, but so long as you use the new Edit > Content Aware you should be fine.