Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Using indexOf()
indexOf function is used to find the character in a String. It will return '-1' on failure i.e. no character found in a String else it will return the position of the character.
Example
@ Special Character Found in a postion 7
Example
public class example
{
public static void main(String[] args)
{
String email="example@gmail.com";
int pos=email.indexOf('@');
if(pos!=-1)
{
System.out.println("@ Special Character Found in a postion "+pos);
}
else
{
System.out.println("@ Special Character Not Found");
}
}
}
Output@ Special Character Found in a postion 7
Difference between Java and Javaw exe
There will be a bit confusion
between java and javaw exes in JDK bin folder, the path is (where the jdk is
placed directory)
c:/Program
Files/Java/JDK/bin/java.exe
Both will do
the similar work and will run in same environment (Windows). But have one key
difference in common.
java.exe is the console app, if want to work
in console executing any java code without any IDE(Eclipse,Netbeans) java.exe will
execute and run.
c:/Program Files/Java/JDK/bin/Java
FirstApp.java
javaw.exe
is windows app (console-less). You can't have Console with javaw.exe. If working in IDE like Eclipse,javaw.exe will run
in the system.
Subscribe to:
Posts
(
Atom
)
