|
|
If there is no such element which we are looking for,
elementFound=driver.findElement(By.name(locatorValue));
what will return into elementfound
if no such element how can we set elementfound to null
|
|
|
|
|
What happens when you try it?
|
|
|
|
|
Hi,I am trying to write a java code for SMS dictionary.This is my sample input and output.
Sample input:
4//the number of inputs to be given
at
on
good
no
Sample output:
66//maximum occurrence is printed here.
The conversion takes place as follows.
at->28
on->66
good->4663
no->66
This is similar to the way in which messages are typed in a basic series mobile. My code displays the conversion but the output should be the number with maximum occurrence like 66 in the above sample.I get NullPointerException while trying to save the values to a buffer.Thanks in advance.
package sms;
import java.util.Arrays;
import java.util.Scanner;
class done
{
String astring;
int m=0;
String buffer[];
String temp1[];
int temp2[];
int b = 0;
char val2[]={'a','b','c'};
char val3[]={'d','e','f'};
char val4[]={'g','h','i'};
char val5[]={'j','k','l'};
char val6[]={'m','n','o'};
char val7[]={'p','q','r','s'};
char val8[]={'t','u','v'};
char val9[]={'w','x','y','z'};
Scanner in=new Scanner(System.in);
@SuppressWarnings("empty-statement")
void fun()
{
System.out.println("Enter the number of strings");
int num=in.nextInt();
System.out.println("enter the strings");
for(int k=0;k<=num;k++)
{
astring =in.nextLine();
b=astring.length();
char c;
for(int i=0;i<b;i++)
{
c=astring.charAt(i);
if((c==val2[0])||(c==val2[1])||(c==val2[2]))
{
System.out.print("2");
temp1[i] =("2");
}
else if((c==val3[0])||(c==val3[1])||(c==val3[2]))
{
System.out.print("3");
temp1[i] =("3");
}
else if((c==val4[0])||(c==val4[1])||(c==val4[2]))
{
System.out.print("4");
temp1[i] =("4");
}
else if((c==val5[0])||(c==val5[1])||(c==val5[2]))
{
System.out.print("5");
temp1[i] =("5");
}
else if((c==val6[0])||(c==val6[1])||(c==val6[2]))
{
System.out.print("6");
temp1[i] =("6");
}
else if((c==val7[0])||(c==val7[1])||(c==val7[2])||(c==val7[3]))
{
System.out.print("7");
temp1[i] =("7");
}
else if((c==val8[0])||(c==val8[1])||(c==val8[2]))
{
System.out.print("8");
temp1[i] =("8");
}
else if((c==val9[0])||(c==val9[1])||(c==val9[2])||(c==val9[3]))
{
System.out.print("9");
temp1[i] ="9";
}
}
temp2[k]=Integer.parseInt(temp1[k]);
}
}
}
class SMS
{
public static void main(String args[])
{
done obj;
obj = new done();
obj.fun();
}
}
|
|
|
|
|
You forgot to allocate any space to your buffer arrays. You could also make that code much neater by using the numeric value of a letter to decide which number it corresponds to.
|
|
|
|
|
Please can someone help with a good document to learn CORE JAVA part? Also, please can you suggest me with some important concepts to get a very good hold on the core part?
Thanks.
|
|
|
|
|
|
u can get easy notes for java
just go to
http://way2java.com/
|
|
|
|
|
How can i get time of sending and receiving messages between computers through time of flight based technique ?
i want the java code for it..
im doing the project called "discover and verification of neighbour position in MANET" ..IF U CAN PLEASE SEND THE JAVA CODE ..
|
|
|
|
|
What does "time of flight" has to do with time APIs in Java?
Anyway, you can work your way around from this Oracle Java developers document[^]. You can get the time before sending the message, and at the time of recieving the message from the network.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
can you please send the java code?
It is for calculating the distance between two position from time information..i need to get the transmission time from one system and reception time of my message in another system..please send the java code for the above..
It is for doing the project called"Discovery and Verification of neighbour position in MANET"..Thank U ..
|
|
|
|
|
|
can you please send the java code?
It is for calculating the distance between two position from time information..i need to get the transmission time from one system and reception time of my message in another system..please send the java code for the above..
It is for doing the project called"Discovery and Verification of neighbour position in MANET"..Thank U ..
|
|
|
|
|
I already told you "don't ask for code". This site is not here to do your work for you. If this project is beyond your abilities then you need to talk to your supervisor/manager about it.
|
|
|
|
|
Does anyone know how to find a median of an array? How do we sort it first?
|
|
|
|
|
|
//created by akshgods
import java.util.*;
class median
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int size=5,temp=0,mid=0,pnt1=0,pnt2=0;
System.out.println("Enter the size of array");
size=sc.nextInt();//taking size for array
int a[]=new int[size];
//taking values in array
System.out.println("Enter the values");
for(int i=0;i<size;i++)
{
a[i]=sc.nextInt();
}
//sorting array with bubbule sort in ascending order
for(int i=0;i<size-1;i++)
{
for(int j=0;j<size-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
//printing values in ascending order
System.out.println("values in ascending order");
for(int i=0;i<size;i++)
{
System.out.print(" "+a[i]);
}
//finding medean logic
if(size%2==0)
{
pnt1=size/2;
pnt2=pnt1-1;
mid=(a[pnt1]+a[pnt2])/2;
System.out.println("\nmidean is= "+mid);
}
else
{
pnt1=(size+1)/2;
pnt1--;
mid=a[pnt1];
System.out.println("midean is= "+mid);
}
}
}
|
|
|
|
|
|
Why is it giving me a zero.
double percent = 0;
if(condition) {
percent = scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane);
System.out.print(scrollpane.getHeight() + " / " + origIcon.getImage().getHeight(scrollpane));
System.out.println(" = " + percent);
} else {
}
This returns 309 / 1668 = 0.0 value should be 0.1852..
I know this is basic but I DON'T KNOW. sorry, too tired I guess but I need this to figure out
Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
|
Because that's what scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane) returns, due to integer datatypes.
I don't know Java, but I expect you could do something like:
percent = scrollpane.getHeight();
percent = percent / origIcon.getImage().getHeight(scrollpane);
|
|
|
|
|
well that gives me an idea.. casting should do the trick
Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
|
|
thank you very much it works
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
|
Hello. Can anybody help me create a program that lets user input positive integers and exits if a negative integer is input? the program that outputs max,min, and average of the integers. i have tried to do it since a week and i am stuck in an infinite while loop
|
|
|
|
|
If you show the code* that is failing then people will try to help you.
*Please ensure your code is formatted between <pre lang="java"></pre> tags so it is readable.
|
|
|
|