Demo entry 6365224

java

   

Submitted by anonymous on May 18, 2017 at 09:47
Language: Java. Code size: 987 Bytes.

package text;

public class phone {
	String a1;
	String a2;
	String phonenumber="010-5678945";
	int x=phonenumber.indexOf('-');
	void phone1()
	{
		phonenumber="010-5678945";
		x=phonenumber.indexOf('-');
	}
	void set(String str,String flag)
	{
		this.a1=this.phonenumber.substring(0, this.x);
		this.a2=this.phonenumber.substring(this.x+1);
		if(flag=="area")
		{
			this.a1=str;
			this.phonenumber=this.a1+"-"+this.a2;
		}
		else if(flag=="number")
		{
			this.a2=str;
			this.phonenumber=this.a1+"-"+this.a2;
		}
	}
	String get(String flag)
	{
		if(flag=="area")
		{
			flag=this.phonenumber.substring(0, this.x);
		}
		else if(flag=="number")
		{
			flag=this.phonenumber.substring(x+1);
		}
		return flag;
	}
	public static void main(String[] args)
	{
		phone tmp=new phone();
		System.out.println("area="+tmp.get("area"));
		System.out.println("number="+tmp.get("number"));
		System.out.println("phonenumber="+tmp.phonenumber);
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).