yugandharr147
BAN USERpublic boolean isEqual(int a,int b){
if((a-b) >0 && (a-b)<0){
return true;
}
return false;
}
in the java
public boolean isEqual(int a,int b)
{
switch(a-b){
case 0:return true;
default: return false;
}
}
//in case of javascript
function isEqual(var a,var b){
if(a-b){
return true;
}
return false;
}
in case of JavaScript
yes.we can write like that .but that code holding extra space for "i" variable and one more thinks is your using "goto" and "label" statements ,now this two are not re-commanded in java.but the above code reduce the program code.
- yugandharr147 July 02, 2014you can write code like this,i think it will give best performance wise.if the count value is initially more then 100 then
count=109
it will execute only one IF condition in best case.
int count= getCount(ds1);
return count<100?
count=count+getCount(ds2) < 100?
count=count+getCount(ds3) < 100?
count=count+getCount(ds4) < 100?
count=count+getCount(ds5):count:count:count:count;
}
- yugandharr147 July 02, 2014public class CareerCup2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuilder str3=new StringBuilder("Gandhi was born in 1969. Gandhi was from gujrat. ");
String oldString="Gandhi";
String newString="mahatma";
System.out.println("before conversion the string:"+str3);
str3.replace(str3.indexOf(oldString), (str3.indexOf(oldString)+oldString.length()), newString);
System.out.println("after conversion the string:"+str3);
}
}
public class CarrerCup1 {
public static void main(String[] args) {
StringBuilder s=new StringBuilder("Welcome Bangalore");
String str="";
for(int i=(s.length()-1);i>=0;i--)
{
if(s.charAt(i)==' '){
str=str+s.charAt(i);
for(int j=0;j<i;j++){
str=str+s.charAt(j);
}
i=0;
}
else{
str=str+s.charAt(i);
}
}
System.out.println(str);
}
}
- yugandharr147 June 30, 2014from this question not getting full data.can u explain with sum more data or tell me that Sting contain only two words or many words .if it contain more then two words then what is the sequence of output string .
- yugandharr147 June 30, 2014Create daemon thread ,add all thread to that daemon thread .that daemon thread won't die until all thread are die.In daemon thread write code to check the thread and give system time slot to next thread based condition .
- yugandharr147 June 29, 2014import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Class1 {
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
File file = new File("C:\\Users\\yugandharr\\Desktop\\sample.txt");
Scanner sc=new Scanner(file);
String str="";
int n=10;
while(sc.hasNext()){
str=sc.nextLine()+"\n"+str;
}
System.out.println(str);
String[] LastN= str.split("\n",n);
for(int i=n-1;i>=0;i--){
System.out.println(LastN[i]);
}
}
}
public static void findThreeDigitNumber(int num)
{
int r=0;
if(num>=1)
{
for(int i=1;i<10;i++)
{
if(num % i==0)
{
int temp=num/i;
for(int j=1;j<10;j++)
{
if(temp%j==0 && temp/j<10)
{
r=(temp/j)*100+(j)*10+num/temp;
}
}
}
}}
System.out.println(r);
}
public static void findThreeDigitNumber(int num)
{
int r=0;
if(num>=1)
{
for(int i=1;i<10;i++)
{
if(num % i==0)
{
int temp=num/i;
for(int j=1;j<10;j++)
{
if(temp%j==0 && temp/j<10)
{
r=(temp/j)*100+(j)*10+num/temp;
}
}
}
}}
System.out.println(r);
}
public boolean test(int n)
{
int temp=n*0.1;
temp=temp*10;
if(n-temp==0 || n-temp==5)
{
return true;
}
else
{
return false;
}
}
}
- yugandharr147 January 22, 2014
- yugandharr147 March 14, 2016