Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Facing java error "cannot be applied to (java.lang.String)"

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Facing java error "cannot be applied to (java.lang.String)"

    hi again.
    first of all thanks to JavaPF..

    now here's my new problem
    i get this error:
    Outcome.java:11: setStudNum(int) in Student cannot be applied to (java.lang.String)
    b.setStudNum("\n0510180");
    ^


    here's my script
    Java Code
    public class Student
    {
    String Name,Course;
    int StudentNumber;
     
    	public void setNme(String inputName)
    	{
    	Name=inputName;
    	}
    	public String getNme()
    	{
    	return Name;
    	}
     
    	public void setStudNum(int inputStudentNumber)
    	{
    	StudentNumber=inputStudentNumber;
    	}
    	public int getStudNum()
    	{
    	return StudentNumber;
    	}
     
    	public void setCrs(String inputCourse)
    	{
    	Course=inputCourse;
    	}
    	public String getCrs()
    	{
    	return Course;
    	}
     
    }

    Java Code
    import java.util.*;
    public class Outcome
    {
    public static void main(String[]args)
    {
    Student a = new Student();
    a.setNme("\nCharles Jaime");
    System.out.print(a.getNme());
     
    Student b = new Student();
    b.setStudNum("\n0510180");
    System.out.print(b.getStudNum());
     
    Student c = new Student();
    c.setCrs("\nB.S. Computer Science");
    System.out.print(c.getCrs());
    }
    }
    Last edited by Deep_4; November 7th, 2012 at 01:35 PM.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: cannot be applied to (java.lang.String)

    Did you see the update I made here:

    http://www.javaprogrammingforums.com...ing-class.html ?

    Does this solve the problem?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 16
    Last Post: August 27th, 2010, 03:30 PM
  2. Conversion of string into integer in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 17
    Last Post: January 23rd, 2010, 09:33 AM
  3. Replies: 5
    Last Post: May 21st, 2009, 02:45 AM
  4. [SOLVED] How to string a decimal number in Java?
    By Lizard in forum Loops & Control Statements
    Replies: 6
    Last Post: May 14th, 2009, 03:59 PM