0
Package
Explain what is the use of packages and java lang .packages In simple way
5 odpowiedzi
+ 1
Azad Shami you're welcome.
0
Package is a collection of related classes and interfaces. They are generally used to avoid name conflicts and moreover you have a much better maintainable code.
You can have more than 1 class with the same name but declared in a different package.
java.lang package is implicitly imported by every Java program that you write because it has most relevant collection of classes for Java language support.
0
package factor;
import java .util.Scanner ;
public class factor
{
public static void main(String[] args) {
int n,i;
Scanner sc =new Scanner (System .in);
System .out.println ("enter a no");
n=sc.nextInt();
System .out.println(" factor of no is");
for (i=1;i<=n;i++)//let assume no10
//factor of 10 is 1,2,5,10
{
if(n%i==0)//we have to check(10%2==0)
System .out .println (i);//2 and so on
}
}
}
When I run the program it show the error that
Java.lang.Noclassdefound Error
Can you explain and solve??
0
Sololearn does not support packages so removing the very 1st line shall do the job.
0
Thank you brother ❣❣❣