DEV Community

Khushi Thakuri
Khushi Thakuri

Posted on

1 1

Basic codes in java.

print

public class hk{
public static void main(String[] agrs){
System.out.println("hello people");
}
}

String

length.
public class bm{
public static void main(String[] agrs){
String name = "khushi thakuri";
System.out.println(name.length());
}
}
result= 14

Replace

public class fk{
public static void main(String[] agrs){
String name = "khannal";
String name2 = name.replace('k','t');
System.out.println(name2);
result=thannal

Substring
public class hk{
public static void main(String[] agrs) {
String name = "khusi and khanaa";
System.out.println(name.substring(0,5));
}
}
result=khusi

Concatenate
public class main{
public static void main(String[] agrs){
String name1 = "baba";
String name2 = "mama";
String name3 = name1 +"and" + name2;
System.out.println(name3);
}
}
result= baba and mama

charAt
public class ss{
public static void main(String[] agrs){
String name = "khusi";
System.out.println(name.charAt(1));
}
}
result = h

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay