#Importing an In or Out Class
31 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @weary estuary! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
you import classes based on their package name
package name?
if you'd have the class ```java
package a.b.c;
public class D { /* code here... */ }
, you would do java
import a.b.c.D;
// ...
D somethingWithD = new D();
// ...
// ...
you don't have packages anywhere, and since both the class you want to use and the class you want to use it from are in the same package (the default one), you don't need to add any imports
that's a special case, if both classes are in the same package, you dont need to import it
so to answer simply, you dont need to add any imports, you just do Out.something(), Out out = new Out(...);, or whatever you want to do with the Out class
ooooh
same with In
but it still returns me the same problem about not being able to resolve the Out in the Out.println(x2); part
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
you need to tell the compiler where the classes are
how do I do that?
oh wait i see, the files are classes
that should work then
what's the code you're working with now
public class Hello {
/**
* @param args
*/
public static void main(String[] args) {
String x2 = "Hello World";
Out.println(x2);
}
}```
is that all of it
yes
try to run ```ps
& 'C:\Program Files\Java\jdk-21\bin\java.exe' -cp 'D:\Users\Your Username\New folder' Hello
It returns Hello World
eeeeeeeh
Could it maybe also be because I saved the data on the D-drive and java and vs code is located on C?
okay it also works after I copied the whole project onto C and did the usual javac
wait both works what is dis magic
thanks you btw!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
