Include a file: Difference between revisions

(→‎QBasic: deleted section; info was incorrect (meant to do this with my last edit) -- see BASIC section for corrected info)
Line 189:
 
<lang j>load 'myheader.ijs'</lang>
 
 
=={{header|Java}}==
To include source code from another file, you simply need to create an object of that other file, or 'extend' it using inheritance. The only requirement is that the other file also exists in the same directory, so that the classpath can lead to it. Since Java is quite particular about their "Class name is the same as file name" rule, if you want to use another file called Class2 in Class1, you don't need to be told a unique filename.
 
Just this would be enough.
<lang Java>
public class Class1 extends Class2
{
//code here
}
</lang>
 
You could also consider creating an instance of Class2 within Class1, and then using the instance methods.
<lang Java>
public class Class1
{
Class2 c2=new Class2();
static void main(String[] args)
{
c2.func1();
c2.func2();
}
}
</lang>
 
=={{header|JavaScript}}==
Following example, if loaded in an HTML file, loads the [http://jquery.com/ jQuery] library from a remote site
Anonymous user